two-dimensional array
need to target the subarray where key id
is equal to a variable $id
and move that target array at the top of main array
$id = 2;
$rows = Array(
[0] => Array(
[id] => 1 [0] => 1
[top] => vid [1] => vid)
// target array
[1] => Array(
[id] => 2 [0] => 2 // target element
[top] => img [1] => img)
[2] => Array(
[id] => 3 [0] => 3
[top] => gall [1] => gall)
)
$target = // subarray having [id] => 2
after selecting the target, I suppose the prodedure is like this:
unset($rows[$target]);
$rows = $target + $rows;
so problem is to select the target subarray