我想將一個$customFieldName
轉換爲一個數組,但我把它作爲字符串取回。我試過如下:Get_post_meta字符串數組到數組
1 TRY
$field = array();
$field = get_post_meta((int)$id[0], $customFieldName, true);
2嘗試
$field = array();
$field = unserialize(get_post_meta((int)$id[0], $customFieldName, true));
我回來的字符串如下所示:
「{\ 「use_own_api \」:假,\ 「google_auth_code \」:\「4 \/hLXqq9X7sX1sOY -K6MhpEZu6bc8fGGADKLnjlcWA-P4 \」,\ 「google_api_key \」:\ 「AIzaSyAJjpxVYfZ0WQPZSPr72DOuKU3X-sXquqM \」,\ 「google_client_id \」:\ 「180054848980.apps.googleusercontent.com \」,\ 「google_client_secret \」:\ 「sdfsd \」 ,\ 「google_access_token \」:\ 「{\\」 \\的access_token 「:\\」 ya29.Ci8YA6-sfsd-asdfas \\」,\\ 「token_type \\」:\\ 「承載\\」,\\ 「expires_in \\」:3600,\\ 「refresh_token \\」:\\ 「1 \/534ewsdcy \\」,\\ 「創建\\」:1467867036} \ 「\ 」ga_active_web_property \「:{\」 __ PHP_Incomplete_Class_Name \ 「:\」 Google_Webproperty \ 「\ 」帳戶ID \「:\ 」7489234 \「,\ 」childLink \「:{\ 」__ PHP_Incomplete_Class_Name \「:\ 」Google_WebpropertyChildLink \「,\ 」HREF \「:\」 HTTPS: \/\/www.googleapis.com \ /分析\/V3 \ /管理\ /賬戶\/7489234 \ /網絡媒體資源\/UA-7489234-1 \ /型材\ 「\ 」類型\「:\」 分析#型材\ 「},\」 創建\ 「:\」 2016-06-28T19:38:17.530Z \ 「\ 」ID \「:\ 」UA-7489234-1 \「,\ 」industryVertical \「:\」 COMPUTERS_AND_ELECTRONICS \「,\」internalWebPropertyId \「:\」11922adsf \「,\」kind \「:\」analytics#webproperty \「,\」level \「:\」「
但是,仍然以字符串形式返回。
任何建議,如何讓陣列回array
。
我感謝您的回覆!
你有沒有試過這個。 $ jArr = json_decode($ jsonString,true); –