Reputation: 259
I have a json_encode element and i have to implode it like that
<?php
$user = json_decode($var);
$fetch_array = implode(",", $user);
?>
with the debug print_f the array result like that
Array( [0] => stdClass Object ( [id] => 4 [name] => Elis )
[1] => stdClass Object ( [id] => 5 [name] => Eilbert ))1
it result a error: Object of class stdClass could not be converted to string
My goal is use this json array with the statment SELECT IN on mysql,
SELECT * FROM table WHERE field IN $user
I tought that i have to implode it. if I delete the function implode it show me (array,array)
How can i do that?
Upvotes: 1
Views: 7596
Reputation: 3778
json_decode returns an object by default. In your case, you need an array. Add 2nd param as true as below:
json_decode($var, true);
Upvotes: 5