例1:
1 <?php 2 $a1=array("a"=>"1","b"=>"2","c"=>"3",1,array(1,2)); 3 $result=array_reverse($a1); 4 print_r($result); 5 ?>
Array ( [0] => Array ( [0] => 1 [1] => 2 ) [1] => 1 [c] => 3 [b] => 2 [a] => 1 )
例2:
1 <?php 2 $a1=array("a"=>"1","b"=>"2","c"=>"3",1,array(1,2)); 3 $result=array_reverse($a1,true); 4 print_r($result); 5 ?>
Array ( [1] => Array ( [0] => 1 [1] => 2 ) [0] => 1 [c] => 3 [b] => 2 [a] => 1 )
测试一下,preserve_keys如果写其它内容,会怎样。
1 <?php 2 $a1=array("a"=>"1","b"=>"2","c"=>"3",1,array(1,2)); 3 $result=array_reverse($a1,1); 4 print_r($result); 5 ?>
Array ( [1] => Array ( [0] => 1 [1] => 2 ) [0] => 1 [c] => 3 [b] => 2 [a] => 1 )
如果preserve_keys为数字,效果跟true一样。
1 <?php 2 $a1=array("a"=>"1","b"=>"2","c"=>"3",1,array(1,2)); 3 $result=array_reverse($a1,false); 4 print_r($result); 5 ?>
改成false,
Array ( [0] => Array ( [0] => 1 [1] => 2 ) [1] => 1 [c] => 3 [b] => 2 [a] => 1 )
与不填写一样。