• Resolved matfr

    (@matfr)


    Hello,

    I saw that in the database the address field is stored like this :

    a:4:{s:14:”street_address”;s:11:”26 Rue test”;s:4:”city”;s:8:”Paris”;s:3:”zip”;s:5:”75001″;s:7:”country”;s:6:”France”;}

    My question is how can I extract those informations so that I can use them in PHP variables ? I need to retrieve each street, city, zip, country individually.

    Thanks.

    -Mat.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @matfr !

    I hope you’re doing well today!

    This format is called serialised format, basically it converts an array to a string that’s easy to store in a database.

    https://www.php.net/manual/en/function.unserialize.php

    Here’s how you extract the data:

    $rawData = 'a:4:{s:14:”street_address”;s:11:”26 Rue test”;s:4:”city”;s:8:”Paris”;s:3:”zip”;s:5:”75001″;s:7:”country”;s:6:”France”;}'; // what you got from the db
    $data = unserialize($rawData);
    echo $data["street_address"];

    Kind regards,
    Pawel

    Thread Starter matfr

    (@matfr)

    Thank you very much !

    -Mat

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Use the address database field’ is closed to new replies.