PHP json_encode

草稿

<?php

$demo1 = array('result' =>true );
echo json_encode($demo1);//{"result":true}

$picsList=array(
    "countTotal"=>2,
    "list"=> array(
        array(
            'name' =>'orabge.jpg',
            'size'=>1233123
        ),
        array(
            'name' =>'apple.jpg' ,
            'size'=>73878 
        )
    )
);

print_r($picsList);//print_r()是专门用来输出数组的函数
echo json_encode($picsList);
//上面输出的结果是{"countTotal":2,"list":[{"name":"orabge.jpg","size":1233123},{"name":"apple.jpg","size":73878}]}


?>

 

 

 

posted @ 2014-01-21 16:55  cart55free99  阅读(195)  评论(0编辑  收藏  举报