PHP insert index as value in array

How can I add to a multidimensional array also the index number of the current added item?

$data_array[] = array('data_array_index' => *the index number of the this array on $data_array*, 'stuff' => 'stuff', etc.)

So when I:

print_r($data_array);

Array(
  [0] => Array(
            data_array_index => 0
            stuff => stuff
         )
  [25] => Array(
            data_array_index => 25
            stuff => stuff
         )
  etc.

Thank you

EDIT

Should this work?

$data_array[] = array('data_array_index' => end($data_array)+1, 'stuff' => 'stuff', etc.)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s