I have an array that has the same structure as this:
$DB = array(
"1" => array(
"name" => "Bob",
"othernames" => "Bill"
),
"2" => array(
"name" => "Gill",
"othernames" => "Gillian"
)
);
I then have a foreach
loop that iterates over the array similar to this:
foreach(array_keys($array) as $id) {
echo $id; // would echo "1" or "2", etc.
// do some other time-consuming operations with $id and the array
}
Some of these time-consuming operations will take longer than others. They will all return a variable with a boolean value.
Currently, I am processing each key one after another, which is causing very long load times.
How can I "iterate" (I'm not sure this is still classed as iteration) over each key in the array simultaneously, so that the page load time will not be affected so severely by the number of items in the array?