cannot use object of type stdclass as array 1

cannot use object of type stdclass as array

$obj_user = json_decode($user, true);

use json_decode($obj, true); 	// add true

Here is what the above code is Doing:
1. We’re using the json_decode() function to convert the JSON string into a PHP object.
2. We’re passing the JSON string to the json_decode() function.
3. We’re passing the second parameter as true so that the function will return an associative array.
4. We’re storing the returned array in a variable named $obj_user.
5. We’re using the var_dump() function to display the contents of the $obj_user variable.

Similar Posts