确保PHP数组只有连续键 [英] Making sure a PHP array has only sequential keys

查看:207
本文介绍了确保PHP数组只有连续键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法有像项的数组:

Is there any way to have an array with items like:

$array[1];
$array[3];
$array[4];

变成一个这样的数组:

Be turned into an array like this:

$array[1];
$array[2];
$array[3];

所以,数组只有连续的数字键?谢谢!

So that the array has only sequential numeric keys? Thanks!

-iMaster

推荐答案

<一个href=\"http://php.net/manual/en/function.array-values.php\"><$c$c>array_values()返回从输入数组中的所有值和索引数值数组。

array_values() returns all the values from the input array and indexes numerically the array.

这篇关于确保PHP数组只有连续键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆