请看下面的代码:
在处理之前有两个数组arrTitle
和arrHref
,
其中arrTitle
内容如下:
arrHref
内容如下:
//将title数组中首元素取出,作为栏目标题 foreach ($arrTitle as &$title) { $text [] = $title[0]; unset($title[0]); } //将href数组中首元素取出,作为栏目url foreach ($arrHref as &$href) { $url [] = $href[0]; unset($href[0]); } print_r($arrTitle); //重新组织title项 $title = array_combine($text, $url); print_r($arrTitle);die;
运行上面的PHP代码,把title和href中每项的首元素取出并去除,然而问题来了,在执行array_combine
之前,$arrTitle
是这样的:
然而在执行array_combine
之后,$arrTitle
变成了这样:
为什么,$arrTitle
的最后一个元素变成了array_combine()
的结果,而array_combine()
函数并没有对$arrTitle
执行了修改?