久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

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

      php怎么將序列化數(shù)據(jù)轉(zhuǎn)為數(shù)組

      轉(zhuǎn)換方法:1、用“unserialize($str)”還原序列化數(shù)據(jù);2、用json_encode()和json_decode()將還原后的數(shù)據(jù)轉(zhuǎn)為數(shù)組類型,語法“json_decode(json_encode(還原數(shù)據(jù)),TRUE)”。

      php怎么將序列化數(shù)據(jù)轉(zhuǎn)為數(shù)組

      本教程操作環(huán)境:windows7系統(tǒng)、PHP7.1版、DELL G3電腦

      我們在開發(fā)的過程中有時會遇到需要把對象或者數(shù)組進行序列化存儲,反序列化輸出的情況。特別是當需要把數(shù)組存儲到 MySQL 數(shù)據(jù)庫中時,就需要將數(shù)組進行序列化操作。

      所有 PHP 里面的值都可以使用 serialize() 函數(shù)將其轉(zhuǎn)換為一個可以存儲的字符串,也就是序列化。

      而想要還原序列化數(shù)據(jù),可以使用unserialize() 函數(shù);該函數(shù)能夠重新把字符串變回 PHP 原來的值,也就是反序列化。

      php將序列化數(shù)據(jù)轉(zhuǎn)為數(shù)組的方法

      1、使用unserialize() 函數(shù)還原序列化數(shù)據(jù)

      unserialize($str)

      其中,$str 為使用 serialize() 函數(shù)序列化后的字符串。如果傳入的字符串不可被反序列化,則會返回 FALSE,并產(chǎn)生一個 E_NOTICE。

      2、將還原后的數(shù)據(jù)轉(zhuǎn)為數(shù)組類型

      使用json_encode函數(shù)將對象轉(zhuǎn)換為json數(shù)據(jù),再使用json_decode函數(shù)將json數(shù)據(jù)轉(zhuǎn)換為數(shù)組。

      <?php $obj=serialize((object)array("11","22","33")); var_dump($obj); $res=unserialize($obj); $arr=json_decode(json_encode($res),TRUE); var_dump($arr); ?>

      php怎么將序列化數(shù)據(jù)轉(zhuǎn)為數(shù)組

      推薦學習:《PHP視頻教程》

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