I have three JSON arrays Now I have decoded(json_decode) to convert it into PHP associative arrays in the result it's showing this result.
Now I want to show this three array in one table like this.
How can I do that please help.
I have three JSON arrays Now I have decoded(json_decode) to convert it into PHP associative arrays in the result it's showing this result.
Now I want to show this three array in one table like this.
How can I do that please help.
This may not be the best answer, if the order of the value and their association to each other in not in the same order. But you can do it like this:
$mainarray = [];
foreach($array1 as $key => $name){
$mainarray[$key] = [
'name' => $name,
'date_addded' => $arrayDate[$key],
'status' => $arrayStatus[$key]
];
}
then you can use the main array in your view to generate the table list.
Checkout this example
$a1=array("red","green");
$a2=array("blue","yellow");
print_r(array_merge($a1,$a2));
UPDATE
in case if you have more tham three or more array
$keys = array('1','2','3');
$names = array('Bob','Fred','Joe');
$emails = array('a@mail.com','b@mail.com','c@mail.com');
$ids = array(A1,A2,A3);
//Create a blank array
$result = array();
foreach ($keys as $id => $key) {
$result[$key] = array(
'name' => $names[$id],
'email' => $emails[$id],
'id' => $ids[$id],
);
}
$get_id=$data->get_id;
$get_product=$data->get_product;
$get_comment=$data->get_comment;
foreach($get_id as $i => $id){
$product = $get_product[$i];
$comment = $get_comment[$i];
echo "$id , $product, $comment<br/>";
}
This solution assumes the $get_id, $get_product, and $get_comment arrays are all indexed the same way.