Jump to content

Archived

This topic is now archived and is closed to further replies.

eddy556

[SOLVED] Accessing associative array via row number

Recommended Posts

How can I access an an access an associative array by number.  For example:

 

$myArray["cat"][0] = "this is at place one";

echo $myArray[0][0];

Share this post


Link to post
Share on other sites

Why would you want to access an assoc array numerically?  Kind of defeats the purpose of an assoc array.

 

 

As far as I know, there is no way to access it numerically.

 

 

You could ghetto it up though with something like:

 

$i = 0;

 

foreach($array as $key => $value) {

    $array[$i++] =& $array[$key];

}

 

 

That would make numerical indexes that are references to the named ones.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.