On 27/03/06, je killen <[EMAIL PROTECTED]> wrote:
> Hi all
> Here is an update on my problem reported with the array_search function.
> to those who directed me to the bug report page, thanks.
> There are a number of reports specific to this function. Maybe event
> someone else has written a fix.
> here is my solution to my problem.

There are no open bug reports for array_search(). Loads of bogus ones though.

array_search() also completely the wrong tool for the job - the code
you posted is much more complicated and slower than it needs to be.

That whole palaver that you go through to produce $reduced could be
replaced with:

   $reduced = array_merge(array(), array_unique($str));

That nested loop you use to produce $final would be rather simpler and
faster if you just flipped $reduced and used a hash lookup.

   $charmap = array_flip($reduced);
   foreach ($str as $char) { $final[] = $charmap[$char]; }

-robin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to