"Cat",2=>"Horse",3=>"Bird"); for ($i = 0; $i "/> "Cat",2=>"Horse",3=>"Bird"); for ($i = 0; $i ">

Home  >  Article  >  Backend Development  >  小弟我想问一下以下这段代码为什么会输出这样的结果?不是应该全部为空吗

小弟我想问一下以下这段代码为什么会输出这样的结果?不是应该全部为空吗

WBOY
WBOYOriginal
2016-06-13 12:39:20829browse

我想问一下以下这段代码为什么会输出这样的结果?不是应该全部为空吗?

<br />
$a1=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird");<br />
for ($i = 0; $i < count($a1); $i++) {<br />
	array_splice($a1,$i, 1);<br />
}<br />
print_r($a1);<br />


效果:
Array ( [0] => Cat [1] => Bird ) 

PHP
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