我有一个像数组
<代码>([0] =>一个[2] =>乙[4] =>C[6] =>D)
我想删除第一个元素,然后重新索引数组以获得输出
<代码>([0] =>乙[1] =>C[2] =>D)
我需要使用哪个 PHP 函数?
<小时>更新
输入数组是
数组([0] =>大批([0] =>一些不需要的文字[1] =>你疯了)[2] =>大批([0] =>我下面的文字[1] =>你疯了)[10] =>大批([0] =>我爱的名言[1] =>你疯了))输出应该像
数组([0] =>大批([0] =>我下面的文字[1] =>你疯了)[1] =>大批([0] =>我爱的名言[1] =>你疯了))With array_splice.
http://www.php.net/manual/en/function.array-splice.php
<前>php > print_r($input);大批([0] => A[2] => B[4] => C[6] => D)php > array_splice($input, 0, 1);php > print_r($input);大批([0] => B[1] => C[2] => D)I have an array like Array
(
[0] => A
[2] => B
[4] => C
[6] => D
)
I want to remove the first element and then re-index array to get the output
(
[0] => B
[1] => C
[2] => D
)
Which PHP function i need to use?
Update
Input array is
Array
(
[0] => Array
(
[0] => Some Unwanted text
[1] => You crazyy
)
[2] => Array
(
[0] => My belowed text
[1] => You crazyy
)
[10] => Array
(
[0] => My loved quote
[1] => You crazyy
)
)
And the output should be like
Array
(
[0] => Array
(
[0] => My belowed text
[1] => You crazyy
)
[1] => Array
(
[0] => My loved quote
[1] => You crazyy
)
)
With array_splice.
http://www.php.net/manual/en/function.array-splice.php
php > print_r($input);
Array
(
[0] => A
[2] => B
[4] => C
[6] => D
)
php > array_splice($input, 0, 1);
php > print_r($input);
Array
(
[0] => B
[1] => C
[2] => D
)
这篇关于PHP删除数组的第一个索引并重新索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
以编程方式将可下载文件添加到 Woocommerce 产品Add programmatically a downloadable file to Woocommerce products(以编程方式将可下载文件添加到 Woocommerce 产品)
获取今天 Woocommerce 中每种产品的总订单数Get today#39;s total orders count for each product in Woocommerce(获取今天 Woocommerce 中每种产品的总订单数)
在 WooCommerce 和电话字段验证问题中添加自定义注Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和电话字段验证问题中添加自定义注册字段
在 Woocommerce 简单产品中添加一个将更改价格的选Add a select field that will change price in Woocommerce simple products(在 Woocommerce 简单产品中添加一个将更改价格的选择字段)
在 WooCommerce 3 中将自定义列添加到管理产品列表Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中将自定义列添加到管理产品列表)
自定义结帐“下订单"按钮输出htmlCustomizing checkout quot;Place Orderquot; button output html(自定义结帐“下订单按钮输出html)