• serialize(),unserialize()


    1.关联数组 序列化
    
    $array = array();
    $array['key'] = 'website';
    $array['value']='www.isoji.org';
    $b = serialize($array);  /*serialize()返回字符串
    echo $b;                       // 输出    a:2:{s:3:"key";s:7:"website";s:5:"value";s:13:"www.isoji.org";}  
    
    
    
    unset($array);  
    $b = unserialize($b);
    print_r($b);                 //输出   Array ( [key] => website [value] => www.isoji.org )
    
    2.索引数组序列化
    $array = array(); 
    $array[] = 'website'; 
    $array[]='www.chhua.com'; 
    $a = serialize($array); 
    echo $a;                  //a:2:{i:0;s:7:"website";i:1;s:13:"www.chhua.com";}
    
    
    
    unset($array); 
    $a = unserialize($a); 
    print_r($a);            //Array ( [0] => website [1] => www.chhua.com )
     
  • 相关阅读:
    python 小练习 5
    python 小练习4
    python 小练习3
    python 小练习2
    遇到后缀名为whl的库的安装方法
    hdu1394Minimum Inversion Number
    Triangle
    codeforces B. Pasha and String
    F
    C
  • 原文地址:https://www.cnblogs.com/zxqblogrecord/p/9063014.html
Copyright © 2020-2023  润新知