I am trying to convert a $customFieldName
to an array, but I get it back as string. I tried the following:
1 Try
$field = array();
$field = get_post_meta((int)$id[0], $customFieldName, true);
2 Try
$field = array();
$field = unserialize(get_post_meta((int)$id[0], $customFieldName, true));
The string I get back looks like the following:
"{\"use_own_api\":false,\"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\\":\\"Bearer\\",\\"expires_in\\":3600,\\"refresh_token\\":\\"1\/534ewsdcy\\",\\"created\\":1467867036}\",\"ga_active_web_property\":{\"__PHP_Incomplete_Class_Name\":\"Google_Webproperty\",\"accountId\":\"7489234\",\"childLink\":{\"__PHP_Incomplete_Class_Name\":\"Google_WebpropertyChildLink\",\"href\":\"https:\/\/www.googleapis.com\/analytics\/v3\/management\/accounts\/7489234\/webproperties\/UA-7489234-1\/profiles\",\"type\":\"analytics#profiles\"},\"created\":\"2016-06-28T19:38:17.530Z\",\"id\":\"UA-7489234-1\",\"industryVertical\":\"COMPUTERS_AND_ELECTRONICS\",\"internalWebPropertyId\":\"11922adsf\",\"kind\":\"analytics#webproperty\",\"level\":\""
However, still I get it back as string.
Any suggestions, how to get the array back as array
.
I appreciate your reply!