I am trying to print an array in reverse order in PHP 7, but it is printed in a strange way.
<?php
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$n);
$arr_temp = fgets($handle);
$arr = explode(" ",$arr_temp);
array_walk($arr,'intval');
$output = "";
for($i = $n - 1; $i>=0; $i--){
$output .= $arr[$i] . " ";
}
print($output);
?>
With the input:
4
1 2 3 4
I get the output:
4
3 2 1
Why is that?