If I am creating an array with several hundred indexes, how much overhead is required for the additional array versus adding a second dimension to an existing array?
I.E. $pages['page']['url'] and $titles['page']['title'] versus $pages['page']['url']['title'] versus $pages['page']['title'], where the last example assumes each index of $pages contains an associative array.
The goal is to be able to be to lookup two attributes of each 'page'. Each 'page' has a 'url' and a 'title', which would be more efficient for memory usage on the arrays? Which for access/storing the data?
Two associative arrays:
// Store the information in arrays
$titles['page1'] = 'Page 1 Title';
$titles['page2'] = 'Page 2 Title';
$urls['page1'] = 'http://www.page1.com';
$urls['page2'] = 'http://www.page2.com';
// Display an example
echo $titles['page1'] . ' is at ' . $urls['page1'];
or one array of arrays:
$pages['page1'] = array( 'title' => 'Page 1 Title', 'url' => 'http://www.page1.com' );
$pages['page2'] = array( 'title' => 'Page 2 Title', 'url' => 'http://www.page2.com' );
// Display an example
echo $pages['page1']['title'] . ' is at ' . $pages['page1']['url'];