Blogger Information
Blog 11
fans 0
comment 1
visits 15486
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP数组重新排序
州爱殇
Original
5733 people have browsed it

$arr = [4=>10,1=>22,9=>55,0=>255];
echo “<pre>“;
echo “返回数组中所有的值并给其建立从0开始递增的数字索引 $arr = [4=>10,1=>22,9=>55,0=>255]; tips: 使用函数array_values()”;
print_r($arr);
echo “<hr>“;
//第一种:获取值 即从零开始递增
$value=array_values($arr);
print_r($value);
//第二种.把键从小到大递增

//1.获取键
$keys=array_keys($arr);
echo “键数组按升序排列是:<br>“;
$keys2=sort($keys,1);
print_r($keys);

echo “<hr>“;
//数组合并
$res3=array_combine($keys,$value);
print_r($res3);

Correcting teacher:灭绝师太灭绝师太

Correction status:qualified

Teacher's comments:举一反三,非常好。
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post