Answer the question
In order to leave comments, you need to log in
PhP nested array how to pass parameter?
Hello everyone, just a quick question. There is the following code:
$data_dst_1 =json_decode($json, true);
$data_dst_2 =json_decode($json2, true);
foreach ($data_dst_1 as $sept_1) { $DataArray_1[] = array("Rx" => $sept_1["Rx"],"sesTxBytes" => $sept_1["Tx"]); }
foreach ($data_dst_2 as $sept_2) { $DataArray_2[] = array("Rx" => $sept_2["Rx"],"sesTxBytes" => $sept_2["Tx"]); }
array_map('function',$DataArray_1,$DataArray_2);
complains if DataArray_1[] and DataArray_2[] are being passed both simultaneously and one at a time. And if I omit the brackets in the code:foreach ($data_dst_1 as $sept_1) { $DataArray_1 = array("Rx" => $sept_1["Rx"],"sesTxBytes" => $sept_1["Tx"]); }
foreach ($data_dst_2 as $sept_2) { $DataArray_2 = array("Rx" => $sept_2["Rx"],"sesTxBytes" => $sept_2["Tx"]); }
Everything is running successfully. But this is not necessary, because only the first line of the array is displayed. Given that the array accepts other dynamic arrays, this can be from 1 to several thousand. I can't figure out what the problem is.
Answer the question
In order to leave comments, you need to log in
you need to create a function/class of operations with a tree-like associative array
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question