-1
People are in need of help, I am carrying some information from Json, as follows::
<?php
$json_data = json_decode(file_get_contents('arquivo3.json'), true);
foreach ($json_data["Result"] as $data) {
echo '<br>Endereço: ' .$data["CreditData"][0]["Addresses"][0]["AddressMain"];
echo '<br>Número: ' .$data["CreditData"][0]["Addresses"][0]["Number"];
echo '<br>Complemento: ' .$data["CreditData"][0]["Addresses"][0]["Complement"];
echo '<br>Cidade: ' .$data["CreditData"][0]["Addresses"][0]["City"];
echo '<br>CEP: ' .$data["CreditData"][0]["Addresses"][0]["ZipCode"];
echo '<br>Familiar: ' .$data["CreditData"][0]["Addresses"][0]["Neighborhood"];
echo '<br>Estado: ' .$data["CreditData"][0]["Addresses"][0]["State"];
echo '<br>País: ' .$data["CreditData"][0]["Addresses"][0]["Country"];
echo '<br>';
// NÃO QUERIA REPETIR A LINHA ABAIXO E COLOCAR AQUI UM LOOP PARA AUTOMATICAMENTE CARREGAR QUANTO FOR NECESSÁRIOS DE ENDEREÇOS
echo '<br>Endereço: ' .$data["CreditData"][0]["Addresses"][1]["AddressMain"];
echo '<br>Número: ' .$data["CreditData"][0]["Addresses"][1]["Number"];
echo '<br>Complemento: ' .$data["CreditData"][0]["Addresses"][1]["Complement"];
echo '<br>Cidade: ' .$data["CreditData"][0]["Addresses"][1]["City"];
echo '<br>CEP: ' .$data["CreditData"][0]["Addresses"][1]["ZipCode"];
echo '<br>Familiar: ' .$data["CreditData"][0]["Addresses"][1]["Neighborhood"];
echo '<br>Estado: ' .$data["CreditData"][0]["Addresses"][1]["State"];
echo '<br>País: ' .$data["CreditData"][0]["Addresses"][1]["Country"];
echo '<br>';
}
?>
QUESTION:
As you can see, I need him to bring the address of a certain person, but some people have more than 1 registered address, so he can bring 1 or 2 or even more than 5 different addresses. How do I create a loop so I don’t have to keep repeating lines?
Dejavu -> https://answall.com/questions/371710/como-ler-esse-exemplo-de-json-correctment/371711
– Andrei Coelho