1

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.

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";}}

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

1

1 Answer 1

1

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);
print_r($unserializeOutput)

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

)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.