Home >Backend Development >PHP Tutorial >How to output json object in php
This time I will show you how to output json objects in PHP. What are the precautions for outputting JSON objects in PHP? The following is a practical case, let's take a look.
An example is as follows:
<!DOCTYPE html> <html> <body> <?php $json = '{"report":{"date":"2012-04-10","content":"abcdefght"}}'; $arr = (array) json_decode($json,true); echo '当前日期是:'. $arr['report']['date']; echo "<br/>"; echo '<pre class="brush:php;toolbar:false">'; print_r($arr); echo ''; foreach($arr as $arrvalue) { foreach($arrvalue as $key=>$value) { echo "[$key] = $value