I’m trying to make up my mind between allowing one of my functions accept either an array of arrays or just an a standard array.
The array with arrays will allow me to verify each array key, but it is not necessary if I am able to see an improved performance from using a standard array.
Is there any performance difference between the two (performance wise)?
e.g.
arrays of arrays
$arr2 = array(
array('isbn' => '1846031249'),
array('isbn' => '0340912081'),
array('isbn' => '0435446576'),
array('isbn' => '1741845467'),
array('isbn' => '0750924721'),
array('isbn' => '1843286432'),
array('isbn' => '011331079X'),
array('isbn' => '9063325819')
);
normal array
$arr2 = array(
'1846031249',
'0340912081',
'0435446576',
'1741845467',
'0750924721',
'1843286432',
'011331079X',
'9063325819'
);
Don’t do an array of arrays! You are needlessly increasing the amount of information you need to store in memory/process through. And in your case, when each value is simply an ISBN, keep track of the array so that you remember what’s in it and scrap the repetitive labelling.