Please see the code below:
There are two arrays before processing arrTitle
and arrHref
,
The content of arrTitle
is as follows:
arrHref
The content is as follows:
//将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;
Run the above PHP code to extract and remove the first element of each item in title and href. However, the problem arises. Before executing array_combine
, $arrTitle
looks like this:
However, after executing array_combine
, $arrTitle
becomes like this:
Why, the last element of $arrTitle
becomes the result of array_combine()
, but the array_combine()
function does not modify $arrTitle
?