HTTPS ipcrs.pbccrc.org.cn PHP json and array conversions

Source: Internet
Author: User
1. Change the array to a JSON string: Json_encode ($arr [, $opti//$options is optional, default is 0

Json_encode ($arr) is generally used. However, when there is a special need, such as the data contains the absolute path of the file, like "/da1/test/123.php", the direct Json_encode will be the forward slash "/" escaped to "\",

At this point you need to add special parameters to the options, options can be selected parameters as follows:

Json_hex_tag (integer) all < and > escaped into \u003c and \u003e. Json_hex_amp (integer) All & escaped into \u0026. Json_hex_apos (integer) All ' escapes into \u0027. Json_hex_quot (integer) All "escapes into \u0022. Json_force_object (integer) causes a non-associative array to output a class (OBJECT) instead of an array. This is especially useful when the array is empty and the recipient needs a Class (Object). Json_numeric_check (integer) encodes all numeric strings into numbers (numbers), such as "1" compiled into 1json_bigint_as_string (integer) to encode large numbers as original characters. Json_pretty_print (integer) Formats the returned data with whitespace characters. Make it more beautiful Json_unescaped_slashes (integer) do not escape/, do not add this option will "/" escaped to "\" Json_unescaped_unicode (integer) to literally encode multibyte Unicode characters (encoded as \uxxxx by default).

2. Change the JSON string to an array: Json_decode ($json _str[,assoc=false]);/$json _str is the corresponding JSON string, assoc is an optional parameter, the default is False

The optional parameters are as follows:

When Assoc is false, Json_decode returns an object, not an array, that can be $obj->attr; to access the property named attr in the object $obj. When Assoc is true, Json_decode returns an array, which can be accessed by Array[key] to access the value of the corresponding key in array

The above describes the HTTPS ipcrs.pbccrc.org.cn PHP json and array conversion, including the content of the https ipcrs.pbccrc.org.cn, I hope that the PHP tutorial interested in a friend helpful.

  • 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.