茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    php數(shù)組轉(zhuǎn)成json格式的方法
    來(lái)源:易賢網(wǎng) 閱讀:2138 次 日期:2015-03-11 11:41:03
    溫馨提示:易賢網(wǎng)小編為您整理了“php數(shù)組轉(zhuǎn)成json格式的方法”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了php數(shù)組轉(zhuǎn)成json格式的方法,實(shí)例分析了php操作數(shù)組及json格式數(shù)據(jù)的方法,需要的朋友可以參考下

    本文實(shí)例講述了php數(shù)組轉(zhuǎn)成json格式的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

    代碼如下:

    function array_to_json( $array ){

    if( !is_array( $array ) ){

    return false;

    }

    $associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) ));

    if( $associative ){

    $construct = array();

    foreach( $array as $key => $value ){

    // We first copy each key/value pair into a staging array,

    // formatting each key and value properly as we go.

    // Format the key:

    if( is_numeric($key) ){

    $key = "key_$key";

    }

    $key = "'".addslashes($key)."'";

    // Format the value:

    if( is_array( $value )){

    $value = array_to_json( $value );

    } else if( !is_numeric( $value ) || is_string( $value ) ){

    $value = "'".addslashes($value)."'";

    }

    // Add to staging array:

    $construct[] = "$key: $value";

    }

    // Then we collapse the staging array into the JSON form:

    $result = "{ " . implode( ", ", $construct ) . " }";

    } else { // If the array is a vector (not associative):

    $construct = array();

    foreach( $array as $value ){

    // Format the value:

    if( is_array( $value )){

    $value = array_to_json( $value );

    } else if( !is_numeric( $value ) || is_string( $value ) ){

    $value = "'".addslashes($value)."'";

    }

    // Add to staging array:

    $construct[] = $value;

    }

    // Then we collapse the staging array into the JSON form:

    $result = "[ " . implode( ", ", $construct ) . " ]";

    }

    return $result;

    }

    希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

    更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄

    更多信息請(qǐng)查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:php數(shù)組轉(zhuǎn)成json格式的方法
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢(xún)回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢(xún)?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報(bào)班

    • 報(bào)班類(lèi)型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢(xún) | 簡(jiǎn)要咨詢(xún)須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專(zhuān)用圖標(biāo)
    聯(lián)系電話(huà):0871-65099533/13759567129 獲取招聘考試信息及咨詢(xún)關(guān)注公眾號(hào):hfpxwx
    咨詢(xún)QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專(zhuān)用圖標(biāo)