我有以下文件,其中包含下一个代码,我试图通过将某些项目添加到数组中来跟踪它们。
header('Content-type: application/json');
$json_output = array();
$json_parcurs = array();
function generate_json_file($depth, &$json_output, $parent_id, &$children = null, $child_nr = null , $percentage = 0,$id_child = null,$type = 0,&$json_parcurs){
[code].....
for($i=0; $i<$nr_of_children; $i++)
{
if (!in_array($firma[$i+1]['vessta_id'],$json_parcurs))
// Run recurence function
if ($firma[$i+1]['shareholder_id'] != '')
{
array_push($json_parcurs,$firma[$i+1]['vessta_id']);
generate_json_file($depth, $json_output, $table_init[1][0], $json_output['children'], $i,$firma[$i+1]['percentage_held'],$firma[$i+1]['vessta_id'],0,$json_parcurs);
}
}
}
generate_json_file(0, $json_output, 0);
echo json_encode($json_output);
我的问题是我收到很多这样的警告:
[05-Jan-2013 22:49:24 UTC] PHP Warning: in_array() expects parameter 2 to be array, null given in
[05-Jan-2013 22:49:24 UTC] PHP Warning: array_push() expects parameter 1 to be array, null given