Re: phpsadness
| From: | Jim Lucas | Date: | Wed, 01 Jun 2011 00:51:08 +0000 |
| Subject: | Re: phpsadness | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313284@lists.php.net to get a copy of this message | ||
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