After array_filter(), how can I reset the keys to go in numerical order starting at 0(在 array_filter() 之后,如何重置键以从 0 开始按数字顺序排列)
问题描述
我刚刚使用 array_filter 从数组中删除了只有值 '' 的条目,现在我想根据从 0 开始的占位符对其应用某些转换,但不幸的是它仍然保留了原始索引.我看了一会儿,什么也没看到,也许我只是错过了明显的,但我的问题是......
I just used array_filter to remove entries that had only the value '' from an array, and now I want to apply certain transformations on it depending on the placeholder starting from 0, but unfortunately it still retains the original index. I looked for a while and couldn't see anything, perhaps I just missed the obvious, but my question is...
如何轻松地将数组的索引重置为从 0 开始并在新数组中按顺序排列,而不是保留旧索引?
How can I easily reset the indexes of the array to begin at 0 and go in order in the NEW array, rather than have it retain old indexes?
推荐答案
如果你调用 array_values
在您的数组上,它将从零重新索引.
If you call array_values
on your array, it will be reindexed from zero.
这篇关于在 array_filter() 之后,如何重置键以从 0 开始按数字顺序排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 array_filter() 之后,如何重置键以从 0 开始按数


基础教程推荐
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01