php - json_encode an array posted from a form -


i have array being passed method insert database.

i've tried:

$names = $_post['names'];  json_encode($names); echo '<pre>' .print_r($names,1). '</pre>'; exit; 

and...

json_encode($names = $_post['names']); 

but neither seem work.. note when debugging print json encoded array, showing array , values - no json :( suggests array being passed fine json encoding not working!

cheers

you have use returned string. json_encode not modify array, arguments passed value.

$names = $_post['names'];  $jsonencoded = json_encode($names); echo $jsonencoded; 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -