【发布时间】:2014-04-09 17:05:59
【问题描述】:
我再次调用这个函数,所以我得到了一些新的 $key,我想将它添加到同一个数组中,这样我就可以检查它是否相同,所以它是独一无二的。像全局数组这样的东西。
function getNodesInfo($node)
{
foreach ($result as $key => $value)
{
$items[]=$key;
}
echo ("-----."\n");
print_r($items."\n");
getNodesInfo($subNode);
}
这是我的输出
-------
Array
(
[0] => author
[1] => title
[2] => genre
[3] => price
[4] => publish_date
[5] => description
)
-------
Array
(
[0] => author
[1] => title
[2] => genre
[3] => price
[4] => publish_date
[5] => description
)
-------
Array
(
[0] => book
)
我希望我的输出看起来像
Array
(
[0] => author
[1] => title
[2] => genre
[3] => price
[4] => publish_date
[5] => description
)
-------
Array
(
[0] => book
)
【问题讨论】:
-
不确定,但也许看看array_unique() function
-
不,它不能使用array_unique
标签: php arrays function return-value