[Solved] show the data from complex json data in php


Assuming that the “new arrivals count” as you call it is the number of elements in the “new_arrivals” array, this works:

$data = json_decode( ... your json string ... );
echo count($data->new_arrivals);

Edit: It’s really hard to understand what you want. How about this?

echo "<table><tr>";
foreach ($data["new_arrivals"][0] as $key => $value) {
    if ($key == "category_ids") continue;
    echo "<th>" . $key . "</th>";
}
echo "</tr>";
foreach ($data["new_arrivals"] as $row) {
    echo "<tr>";
    foreach ($row as $key => $value) {
        if ($key == "category_ids") continue;
        echo "<td>" . $value . "</td>";
    }
    echo "</tr>";
}
echo "</table>";

7

solved show the data from complex json data in php