' + ")");" That’s it."/> ' + ")");" That’s it.">
Home > Article > Backend Development > How to convert php json to js
php json to js method: first create a PHP sample file; then use "eval("(" '' ")");" to convert json to js array.
Recommended: "PHP Video Tutorial"
php background json to js array
1. String
$this->assign('id',$id); var health_id = '<?php echo $id;?>';
2-1 array
$this->assign('cycle', ArchivesUtil::CYCLE); var cycle = eval("(" + '<?php echo json_encode($cycle);?>' + ")");
or
var mobile = "<?php echo $cycle['mobile']; ?>";
2-2
$this->assign('arr', json_encode($arr)); Var arr = {$arr};
Example: json to js array, traverse key value
--------------------- -------------------------------------------------- --------------------------------------------------
tp5
var info = {$info|raw};
The above is the detailed content of How to convert php json to js. For more information, please follow other related articles on the PHP Chinese website!