php - Implode JSON object -


below given, code:

$array=$_post[number]; $jstring = json_decode($array,true);  $sa = "'".implode("','",$jstring)."'"; 

the error given below.

warning: implode() [function.implode]: invalid arguments passed <root> on line <line no> 

number json object. can me out? please. thanks in advance.

edit: number json string. need comma separated. number holds phone numbers mobiles contact. need each number used in sql query.


problem fixed: fixed problem. sharing others.

$array = $_post[number]; $json = (array) json_decode($array,true);  $sa = "'" . implode(',', $json) . "'"; 

if you're having trouble debugging, use var_dump or in combination gettype() around argument you're trying implode. never need implode json objects, decoded find. make sure know difference between csv (comma separated values) , json.

csv:

believe,it,or,not,i,am,csv 

whereas json:

{"itbetrue":"ibejson"} {"iam":["an","array","in","json"]} 

if you're trying json decoded array's values, use this:

$csv = implode(',', array_values($json)); 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -