I have an array to which I want to access all the columns of the json array. I am trying it this way but I can only access one column of the array. How can I access all the columns of the array?
<?php
$jsonobj = '{
"codigo": "00",
"descripcion": "Consulta exitosa",
"movimientos": [
{
"comercio_desc": "ATIPICO RIVERA",
"fch_com": "06/01/21",
"importe": "10000",
"mov_tp": "D",
"referencia_nro": "100530994259",
"tarjeta": "6274311750000090"
},
{
"comercio_desc": "COPETROL VILLA MADRID",
"fch_com": "06/01/21",
"importe": "350000",
"mov_tp": "D",
"referencia_nro": "100530994259",
"tarjeta": "6274311750000090"
}
]
}';
$decodedJson = json_decode($jsonobj, true);
?>
Here in this table it should show all the records Code description trade_desc fch_com amount mov_tp reference_card number
<tr>
<td class="text-nowrap text-inverse text-center"> <?php echo $decodedJson["codigo"]; ?> </td>
<td class="text-nowrap text-inverse text-center"> <?php echo $decodedJson["descripcion"]; ?></td>
<td class="f-w-600 text-muted text-center"><?php echo $decodedJson["movimientos"][0]["comercio_desc"]; ?> </td>
<td class="f-w-600 text-muted text-center"><?php echo $decodedJson["movimientos"][0]["fch_com"]; ?> </td>
<td class="f-w-600 text-muted text-center"><?php echo $decodedJson["movimientos"][0]["importe"]; ?> </td>
<td class="f-w-600 text-muted text-center"> <?php echo $decodedJson["movimientos"][0]["mov_tp"]; ?></td>
<td class="f-w-600 text-muted text-center"> <?php echo $decodedJson["movimientos"][0]["referencia_nro"]; ?></td>
<td class="f-w-600 text-muted text-center"><?php echo $decodedJson["movimientos"][0]["tarjeta"]; ?> </td>
</td>
</tr>
</tbody>
</table>
Remember to put everything in a FOR: for example:
And so you show your records