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

请问!关于php数组

WBOY
WBOYOriginal
2016-06-13 13:52:311016browse

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

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

Statement:
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