How To Use Json In PHP Example
Hello Dev,
As we speak, i we are going to present you tips on how to use json in PHP instance. This text provides you with easy instance of tips on how to use json in PHP instance. you’ll learn to use json in PHP instance.
php has some built-in capabilities to deal with json to given two perform in php.
-json_encode()
-json_decode()
So let’s observe few step to create instance of tips on how to use json in PHP instance.
json_encode()
<!doctype html> <html> <physique> <?php $age = array("php"=>35, "laravel"=>37, "html"=>43); echo json_encode($age); ?> </physique> </html>
Output:
{"php":35,"laravel":37,"html":43}
json_decode()
<!doctype html> <html> <physique> <?php $jsonobj = '{"php":35,"laravel":37,"html":43}'; print_r(json_decode($jsonobj)); ?> </physique> </html>
Output:
stdclass object ( => 35 [laravel] => 37 => 43 )
Komentar
Posting Komentar