jarvis Posted January 27, 2016 Share Posted January 27, 2016 Hi I really hope someone can help me with this. I have the following: $location = (array) ( unserialize(get_post_meta($post_id, $test, true)) ); print_r ($location); This outputs: a:3:{s:7:"address";s:38:"1 Test Way, Test Town, Sussex AB12 3BC, UK";s:3:"lat";d:50.12396349999999932833816274069249629974365234375;s:3:"lng";d:0.1235546000000000272933675660169683396816253662109375;} If I do: $test = (unserialize('a:3:{s:7:"address";s:38:"1 Test Way, Test Town, Sussex AB12 3BC, UK";s:3:"lat";d:50.12396349999999932833816274069249629974365234375;s:3:"lng";d:0.1235546000000000272933675660169683396816253662109375;}')); Then the following works: $geo_address = $test['address']; echo $geo_address; And it displays what I need! Why then does the following not work: $test = (unserialize( get_post_meta($post_id, $test, true) )); Surely its the same thing? Any help is much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/300677-splitting-a-serialized-array/ Share on other sites More sharing options...
Solution Barand Posted January 27, 2016 Solution Share Posted January 27, 2016 unserializing once gave you a serialized string which you then unserialized to get the array. Looks like your original was serialized twice. 1 Quote Link to comment https://forums.phpfreaks.com/topic/300677-splitting-a-serialized-array/#findComment-1530483 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.