Re: [PHP4BETA] suggestion for new function str_change(string str,array
| From: | Andrei Zmievski | Date: | Sat, 20 Nov 1999 19:22:47 +0000 |
| Subject: | Re: [PHP4BETA] suggestion for new function str_change(string str,array | ||
| References: | 1 2 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-6594@lists.php.net to get a copy of this message | ||
On Sat, 20 Nov 1999, Rasmus Lerdorf wrote:
> Yes, I like this. How about just naming it flip() ? Or perhaps
> array_flip()? There are all sorts of uses for this function on its
> own. We'd have to figure out what to do in the case of:
>
> $a[0]="abc";
> $a[1]="abc";
>
> Does $a[abc] become 0 or 1 after the flip?
>
> Or perhaps it becomes 2 on the theory that it might be cool to count the
> number of instances of a particular index. I guess the behaviour could be
> chosen with an argument. The choices being:
>
> - Select lowest value for multiply occurring indices
> - Select highest value for multiply occurring indices
> - Count number of occurences of index and make that the value for that index
We already have array_count_values() for that. And array_keys() can take
a second argument to search for a value and return an array of keys at
which it occurs.
-Andrei
A room without books is like a body without a soul.
-- Marcus Tullius Cicero (106-43 B.C.)