Jump to content

splitting a serialized array


Go to solution Solved by Barand,

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/300677-splitting-a-serialized-array/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.