Php has a backslash added to the json string submitted by the form. If you encounter some string processing problems, please find a solution.

Source: Internet
Author: User
Pipeline & quot;] submit the above string in the form. php receives and outputs the string. The result is [& quot; Pub... ["/Public/editor/php /.. /attached/image/20150115/20150115094109 _33178.jpg ","/Public/editor/php /.. /attached/image/20150115/20150115094110 _19764.jpg "]
The string above the form submission,
Php receives and outputs The result [\ "/Public/editor/php /.. /attached/image/20150115/20150115094109 _33178.jpg \ ", \"/Public/editor/php /.. /attached/image/20150115/20150115094110 _19764.jpg \ "]

Baidu used stripslashes to remove the backslash and use json_decode () for conversion. The result is blank.

$ Img = stripslashes ($ data ['img ']); $ img_list = json_decode ($ img); $ test =' ["/Public/editor/php /.. /attached/image/20150115/20150115094109 _33178.jpg ","/Public/editor/php /.. /attached/image/20150115/20150115094110 _19764.jpg "] '; // The content of $ test is the string if ($ test = $ img) echo 1 in the input box; // if statement is not true, no output 1;

What is the situation...

Reply content:

["/Public/editor/php/../attached/image/20150115/20150115094109 _33178.jpg", "/Public/editor/php/../attached/image/20150115/20150115094110 _19764.jpg"]
The string above the form submission,
Php receives and outputs The result [\ "/Public/editor/php /.. /attached/image/20150115/20150115094109 _33178.jpg \ ", \"/Public/editor/php /.. /attached/image/20150115/20150115094110 _19764.jpg \ "]

Baidu used stripslashes to remove the backslash and use json_decode () for conversion. The result is blank.

$ Img = stripslashes ($ data ['img ']); $ img_list = json_decode ($ img); $ test =' ["/Public/editor/php /.. /attached/image/20150115/20150115094109 _33178.jpg ","/Public/editor/php /.. /attached/image/20150115/20150115094110 _19764.jpg "] '; // The content of $ test is the string if ($ test = $ img) echo 1 in the input box; // if statement is not true, no output 1;

What is the situation...


  

For more information, seearray_diff

After stripslashes var_dump, check whether it is a legal json string. Is there a double quotation mark for the entity?

Thank you @ star001007 for reminding you that the quotation marks do not need to be filtered. The json string is originally caused. The initiator can directly use json_decode.


   

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.