Home > Backend Development > PHP Tutorial > 请问!关于php数组

请问!关于php数组

WBOY
Release: 2016-06-13 13:52:31
Original
1073 people have browsed it

请教!关于php数组!
我原来建立的数组是按0,1,2,3索引的,因为里面有重复的值,我用了array_unique函数,这样重复的去掉了,但是索引就不能连续了,不知道有没有办法可以按现在的排序重新按0,1,2,3这样索引的?

------解决方案--------------------
$newArray = array();
$i = 0;
foreach($oldArray as $v) {
$newArray[$i++] = $v;
}
unset($oldArray);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template