Home » Php » php – String format from Woocommerce RESTful API

php – String format from Woocommerce RESTful API

Posted by: admin February 25, 2020 Leave a comment


I’m currently working with woo-commerce RESTful API and booking plugin.

I need to parse this string from the “_wc_booking_availability” JSON field.


But I can’t understand which format is. Seem JSON but also contain other elements.

How to&Answers:

This is a serialized string, use PHP unserialize() method, which will return an array like below.

$serializedStr = 'a:1:{i:0;a:5:{s:4:"type";s:6:"custom";s:8:"bookable";s:3:"yes";s:8:"priority";i:10;s:4:"from";s:10:"2019-12-11";s:2:"to";s:10:"2020-03-26";}}';
$unserializeOutput = unserialize($serializedStr);

    [0] => Array
            [type] => custom
            [bookable] => yes
            [priority] => 10
            [from] => 2019-12-11
            [to] => 2020-03-26