我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

使数组键在php [duplicate]中再次从0开始

This question already has an answer here:

  • Rebase array keys after unsetting elements 8 answers

I have an array called $Compare, I used the print_r() function in php:

Array ([2] => Broccoli, raw [3] => Candies, butterscotch [4] => Celery, raw [10] => Apricots, raw)

I want it the keys to be in the correct order: 0,1,2,3 not 2,3,4,10!

In the end it should look like this:

Array ([0] => Broccoli, raw [1] => Candies, butterscotch [2] => Celery, raw [3] => Apricots, raw)
</div>

Use array_values:

$Compare = array_values($Compare);

近期文章

  • 从Magento Enterprise迁移到社区
  • 尝试在特定日期之后从多个mysql表中进行选择
  • PHP,MySQL,列出两个表之间没有链接的记录?
  • php - 解析单个值到android
  • Codeigniter - 在文件夹索引中制作页面
  • 无法解密签名的S / Mime消息
  • 使用PDO的php / mysql DateTime格式
  • laravel检查模型的字段是否为空
  • PHP查找并替换某些字符串模式
  • PHP Form POST自动化。 你的想法?
  • 获取测试用例所属的类phpunit
  • 将Wordpress多站点移动到子文件夹中的localhost
  • php表格在预定时间/日期发送电子邮件[关闭]
  • Opcode如何决定它缓存的数据的密钥?
  • 18位Julian Date / TimeStamp PHP转换?
  • 使用sql中的早期值获取现有表单
  • php函数调用直接作为html表单动作
  • 从不同的计算机访问应用
  • 尝试在Windows上使用PEAR安装Predis
  • 如何使用javascript评估字符串中的字符串

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华