0
"a:3:{s:3:\"lat\";s:9:\"5.9611959\";s:3:\"lng\";s:11:\"116.0973403\";s:7:\"address\";s:85:\"Lot No. GA1, GA2 & GA3, Ground Floor, City Mall, Kota Kinabalu, 88000 Sabah, Malaysia\";}"

This is the value returned from get_post_meta["wilcity_location"], how can i extract the 5.9611959 and 116.0973403?

User863
  • 19,346
  • 2
  • 17
  • 41
  • 1
    That looks like serialized data, try https://stackoverflow.com/questions/8641889/how-to-use-php-serialize-and-unserialize – Nigel Ren Jun 29 '21 at 06:03

1 Answers1

1

You have serialised data - you need to first use unserialize and analyse the underlying data structure - in this case an array.

$s="a:3:{s:3:\"lat\";s:9:\"5.9611959\";s:3:\"lng\";s:11:\"116.0973403\";s:7:\"address\";s:85:\"Lot No. GA1, GA2 & GA3, Ground Floor, City Mall, Kota Kinabalu, 88000 Sabah, Malaysia\";}";
$data=unserialize($s);
$lat=$data['lat'];
$lng=$data['lng'];

echo $lat, $lng;
Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46