Cris Denolatter Cris Denolatter - 3 months ago 12
PHP Question

How can I parse this string? (about wordpress)

I wanna parse this code:

a:4:{s:7:"arrival";i:1472256000;s:9:"departure";i:1472342400;s:6:"adults";s:1:"1";s:9:"childrent";s:4:"None";}


I wanna get the 1472256000 and 1472342400 with PHP. How can I do this?

Thanks

Answer

That's a serialized string. So all you have to do is unserialize it.

$str = 'a:4:{s:7:"arrival";i:1472256000;s:9:"departure";i:1472342400;s:6:"adults";s:1:"1";s:9:"childrent";s:4:"None";}';

$str = unserialize($str);

echo $str['arrival'];

echo $str['departure'];