Connecting Tech Pros Worldwide Help | Site Map

arrays: howto convert assoc to numeric

Randell D.
Guest
 
Posts: n/a
#1: Jul 17 '05

Folks,

If I have a numeric array similar to the following:

$tmpArray[0]="alpha";
$tmpArray[1]="beta";
$tmpArray[2]="charlie";

I can break it down like so

list($first,$second,$third)=$tmpArray;

This would mean $first="alpha", $second="beta" and $third="charlie"

However, when I have an associate array like so

$tmpArray["one"]="alpha";
$tmpArray["two"]="beta";
$tmpArray["three"]="charlie";

and do

list($first,$second,$third)=$tmpArray;

Then $first, $second, $third do not have values - Can someone give me an
environmentally friendly workaround to make this work? I can think of
explodes/implodes and a number of other methods, but I had believed I could
reference the first element in an associate array with a zero... and the
next with a numeric one, but that does not seem to be the case...

all help, via the newsgroup would be much appreciated, thanx

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?


Fabian Wleklinski
Guest
 
Posts: n/a
#2: Jul 17 '05

re: arrays: howto convert assoc to numeric


Hi Randell,

what about using array_values() to convert the array
into a an array with numeric indices?

Greetings from Frankfurt/Germany,

Fabian Wleklinski


Randell D.
Guest
 
Posts: n/a
#3: Jul 17 '05

re: arrays: howto convert assoc to numeric



"Fabian Wleklinski" <Wleklinski.NNTP@eWorks.de> wrote in message
news:bmgcv3$c60@library1.airnews.net...[color=blue]
> Hi Randell,
>
> what about using array_values() to convert the array
> into a an array with numeric indices?
>
> Greetings from Frankfurt/Germany,
>
> Fabian Wleklinski
>
>[/color]
Danke! oder "lovely juvely" von Irish man im Canada.

(Im 1992 Ich habe mine wohn platz im Neuisenberg (oust Frankfurt bei 5km) -
meine deutsche is nicht gut aber ich habe gans gut times im Deutscheland)


Closed Thread