将数组中的值取出并重新排序
16lz
2021-08-11
取出数组中的值并重置索引
<?php
$arr = [ 4 => 10, 1 => 22, 9 => 55, 0=>255];
$res = array_values($arr);
printf('<pre>%s</pre>',print_r($res,true));
<?php
$arr1 = [ 4 => 10, 1 => 22, 9 => 55, 0=>255];
$res1 = [];
foreach($arr1 as $k => $v)
{
array_push($res1,$v);
}
echo '<pre>';
print_r($res1);
<?php
$arr2 = [ 4 => 10, 1 => 22, 9 => 55, 0=>255];
$res2[] = array_shift($arr2);
$res2[] .= array_shift($arr2,);
$res2[] .= array_shift($arr2,);
$res2[] .= array_shift($arr2,);
echo '<pre>';
print_r($res2);
更多相关文章
- php灭绝手把手亲传数组索引重建
- PHP数组重新排序
- 返回数组中所有的值并给其建立从0开始递增的数字索引
- zy0810
- zy0805-1
- php基础编程作业-0805
- 利用php循环遍历及运算法则实现重新组合数组与计算器实例两则
- 请实例演绎你对回调函数与递归函数的理解?
- PHP基础课第四次作业