例如:
<?php
//定义一个数哗冲闭组,判尘用于保存读取到的数据
$contents = array()
$query = mysql_query("select * from table")
//遍历数据表
while($array = mysql_fetch_array($query)){
$contents[] = $array
}
print_r($contents)
//然后循环数组,或者通过键名使用数组
foreach($contents as $value){
print_r($value)
}
echo $contents[0]['字段名称乱裂']
?>
$str='{"data":[{"name":"111","img":"748.jpg","dz":"uang","sz":"22"},{"name":"222","img":"888.jpg","dz":"ngzhu","sz":"13"},{"name":"333"桐禅,"img":"999.jpg","dz":"ve","sz":"27"}]}'$json=json_decode($str,true)
echo $json['data'][0]['name']."<br />"
echo $json['data'][0]['img']."<br />"
echo $json['data'][0]['dz']."<br />"
echo $json['data'][0]['sz'返帆]."<br />"
//或者
$json=json_decode($str)
echo $json->data[0]->name."<br />"
echo $json->data[0]->img."<br />"
echo $json->data[0]->漏轮雹dz."<br />"
echo $json->data[0]->sz."<br />"
数据悔州库提到的数据一般是资源类型蚂前键的,要逐一读出,添闷巧加到数组while($row = mysql_fetch_assoc($res)){
$data[] = $row
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)