On Sat, May 28, 2011 at 1:34 PM, Andre Polykanine <an...@oire.org> wrote:

> Hello Nathan,
>
> Do you mean $x{8}?
>

yup, that or $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";
>

this just looks like you're after a quick way to populate an array.


> // I wish that worked
> $alphabet_array=explode('', $alphabet);
> $letter_numbers=array_flip($alphabet_array);
>

do you remember what you needed it for?  w/ the array access notation you
can get at any letter by index or you can get any index by letter.

$alphabet="abcdefghijklmnopqrstuvwxyz";

echo $alphabet[1]; // b
echo strpos($alphabet, 'b'); // 1


> 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.


It would be nice to hear what the use-case is for this issue.

-nathan

Reply via email to