0
I have a $array variable that contains array values that were received from a JSON.stringify(venc)
[
{"Nº da Parc":"1","Data do pagamento":"06/04/2017","valor a pagar":"R$ 50,00"},
{"Nº da Parc":"2","Data do pagamento":"06/05/2017","valor a pagar":"R$ 50,00"},
{"Nº da Parc":"3","Data do pagamento":"06/06/2017","valor a pagar":"R$ 50,00"},
{"Nº da Parc":"4","Data do pagamento":"06/07/2017","valor a pagar":"R$ 50,00"},
{"Nº da Parc":"5","Data do pagamento":"06/08/2017","valor a pagar":"R$ 50,00"}
]
I was able to display only with the echo $array;
.
How do I go through this variable?
I tried to use the
foreach($array as $d){
echo $d;
}
and displays nothing
and trying to use $arr = json_decode($array);
the php file gives error,
No message, just red on Chrome’s bugger
In PHP, associative arrays are also defined between
[]
, nay{}
, outside that is not used:
in the assignment and yes=>
. See working on Repl.it– Woss
is because these values came from JSON.stringify(venc); ai in php I’m looking forward to going through them
– adventistaam
But if it’s coming this way in PHP, you need to convert JSON to array instead. For this, there is the function
json_decode
.– Woss
every time I do
$var = json_decode($array)
gives error in php file. Usingvar_dump(json_decode($array)
works, but I’d like to scroll through to show in an organized way. How to convert json to array?– adventistaam
With this function. Edit your question and post all your code. It’s hard to understand what you’re doing. Put together the error that gives.
– Woss
but the file only turns red on that Chrome bugger and doesn’t say what error is
– adventistaam