Ask what format data this is

Source: Internet
Author: User
What is the format of this data?
a:4:{i:0;i:392;i:1;i:393;i:2;i:394;i:3;i:395;}
This is read from the database. Judge this is_array return 1
That is the array type. How can this be converted to a string or to JS use it? Thank you

------Solution--------------------
This is the PHP serialization (serialize) data
It's impossible to return 1 with Is_array.
Unless you do the deserialization (unserialize)

$a = unserialize (' a:4:{i:0;i:392;i:1;i:393;i:2;i:394;i:3;i:395;} ');
Echo ' ['. Join (', ', $a). ']';
Or
echo Json_encode ($a);
[392,393,394,395]
You can use it for JS.
------Solution--------------------
1, the serialized data first uses unserialize to deserialize, obtains the original array;
2, if you want to pass the PHP array to JS, it must be converted to JSON, and then JS access to JSON data
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.