我想将一个$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); –