3
I have a Curl statement that invokes a WS. The answer to this WS is saved via:
$reference = var_dump(json_decode($exec, true));
return $reference;
Since I have this in one function, in the other file I read as follows:
$var = ob_get_clean();
This is where I echo and give the result below:
array(4) {
["InvoiceIdOut"]=>
int(945)
["FiscalDocumentNumber"]=>
string(7) "AAAA945"
["InvoiceURL"]=>
string(34) "http://teste.pt/maistestes/AAAA945"
["ErrorMessage"]=>
NULL
}
However, I don’t understand how I can remove the data and store it in variables.
If this is the array resulting from the JSON conversion, the solution is a simple access to the variable that stores this array.
$resultado['InvoiceIdOut']
. If the answers below are not working it is likely that you have not kept the result ofjson_encode()
– fernandosavio
It seems to me that the error is in "var_dump" because it does not touch anything, it is a "void". Associate the direct variable to json_decode.
– Pagotti