On 5/28/2011 12:34 PM, Andre Polykanine wrote:
> Hello Nathan,
>
> Do you mean $x{8}?
> That is good but not for all situations.
> I need sometimes to make an array with letters as keys and numbers as
> values, like this (I give English alphabet just as an example, so
> please don't suggest str_split):
> $alphabet="abcdefghijklmnopqrstuvwxyz";
> // I wish that worked
> $alphabet_array=explode('', $alphabet);
> $letter_numbers=array_flip($alphabet_array);
>
> this is just one case I encountered some time ago. Yes, I made this by
> separating letters with commas... but it's not the unique case when I
> need it.
Why not do it the other way around...
$alphabet_array=range('a','z');
$alphabet=join($alphabet_array);
$letter_numbers=array_flip($alphabet_array);
Jim Lucas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php