Here you go:
<?php
$array = array(
array(1,2),
array(3,4),
array(5,6),
array(7,8)
);
function processArray(&$array) {
for ($i = 0; $i < count($array); $i++) {
if ($array[$i][0] > 4) {
$array[$i][0] = $array[$i][0] - 3;
}
if ($array[$i][1] < 5) {
$array[$i][1] = $array[$i][1] + 3;
}
}
}
processArray($array);
print_r($array);
Outputs:
Array ( [0] => Array ( [0] => 1 [1] => 5 ) [1] => Array ( [0] => 3 [1] => 7 ) [2] => Array ( [0] => 2 [1] => 6 ) [3] => Array ( [0] => 4 [1] => 8 ) )
1
solved Multi-dimensional PHP array index