亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    json如何轉(zhuǎn)php

    json如何轉(zhuǎn)php

    json如何轉(zhuǎn)php?

    json_decode是php5.2.0之后新增的一個(gè)PHP內(nèi)置函數(shù),其作用是對(duì)JSON格式的字符串進(jìn)行編碼.

      json_decode的語法規(guī)則:

      json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )

      json_decode接受一個(gè)JSON格式的字符串并且把它轉(zhuǎn)換為PHP變量 ,當(dāng)該參數(shù)$assoc為TRUE時(shí),將返回array,否則返回object。

      JSON 格式的字符串

      $json = '{"a":"php","b":"mysql","c":3}';

      其中a為鍵,php為a的鍵值。

      實(shí)例:

    <?php    $json = '{"a":"php","b":"mysql","c":3}';   $json_Class=json_decode($json);    $json_Array=json_decode($json, true);    print_r($json_Class);    print_r($json_Array);          ?>

      程序輸出:

      stdClass Object (   [a] => php   [b] => mysql   [c] => 3 )   Array (   [a] => php   [b] => mysql   [c] => 3 )

      在上面代碼的前提下

      訪問對(duì)象類型$json_Class的a的值

    echo $json_Class->{'a'};

      程序輸出:php

      訪問數(shù)組類型$json_Array的a的值

    echo $json_Array['a'];

      程序輸出:php

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)