Reputation: 14990
I'm trying to convert a json string into an array with php.
My php version is 7.0
PHP Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\json_decode()
$adjunto1 = $value['archivo'];
$adjunto2 = json_decode($adjunto1, TRUE); //this is teh line with the error
string(155) "{"nombre":["ejemploxls"],"archivoContenido":["id.--ejemploxls--fecha-26-04-2020-10-08.xls"],"fecha":["26-04-2020-10-08"],"size":[5632],"extension":["xls"]}"
When I converted the array to a json string using json_encode(), the array looked like this:
array(5) {
["name"]=>
string(11) "ejemplo.xls"
["type"]=>
string(24) "application/vnd.ms-excel"
["tmp_name"]=>
string(14) "/tmp/php7M0gVS"
["error"]=>
int(0)
["size"]=>
int(5632)
}
What is this error? What is GuzzleHttp?
Upvotes: 3
Views: 2258
Reputation: 458
Seems that you have some kind of implicit import from GuzzleHttp.
Guzzle is an extensible PHP HTTP client.
Here is a wrapper for json_decode
php-function from GuzzleHttp namespace, that may cause your problem.
As a quick soluiton just add a slash before function call:
$adjunto2 = \json_decode($adjunto1, TRUE);
If you want to obtain much more detailed answer from me, plese, add a list of you use-statements from beginning of your php-file. Also list of includes
(if there is any) would be helpful. I need some more context to be more precise.
Upvotes: 2