I have a multi dimensional array, which is printed out. But it is printed in reverse order how I need. But when I try to use array_reverse() it outputs almost random values:
for($j=0; $j<count($positions);$j++){
$temp[$j]=strlen($positions[$j]);
}
array_push($GLOBALS['lengths'],$temp);
and when I echo $lengths I get(as it should be, but in reverse order):
1 1
2 1
but when I use array_reverse($GLOBALS['lengths']) I get:
4 1
2 1
where might be the issue?
Thats the code that I use:
for($j=0; $j<count($positions);$j++){
$temp[$j]=strlen($positions[$j]);
}
array_push($GLOBALS['lengths'],$temp);
$lengths=array_reverse($GLOBALS['lengths']);
$positions? Is it an array of strings or an array of arrays? I noticed you are usingstrlenand notcount.array_reverse($GLOBALS['lengths'], true);to preserve keys it will give a good hint.$lengths