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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
