I'm going to convert an array to JSON.
The array was originally output like this
Print_r ($arrary);//Output result: Array ([0] = upload/2013/05/09/14303.jpeg [1] = upload/2013/05/09/14300.jpeg [2] = = Upload/2013/05/09/148.jpeg [3] = upload/2013/05/09/187.jpeg [4] = upload/2013/05/09/14296.jpeg [5] = Upload /2013/05/09/203.jpeg) $jarr =json_encode ($arrary);//Convert the array to Jsonprint_r ($jarr);//output result: ["upload\/2013\/05\/09\/ 14303.jpeg "," Upload\/2013\/05\/09\/14300.jpeg "," Upload\/2013\/05\/09\/148.jpeg "," upload\/2013\/05\/09\/187. " JPEG "," Upload\/2013\/05\/09\/14296.jpeg "," Upload\/2013\/05\/09\/203.jpeg "]
What's going on, why doesn't JSON have keys? Not supposed to be "0": Upload/2013/05/09/14303.jpeg? and the original array of the URL in the memory of many more "\" originally only "/", this is what is going on?
Reply to discussion (solution)
JSON data format is like this, JS in the call is no problem.
JSON data format is like this, JS in the call is no problem.
But I see the online tutorials are not all "0": Upload/2013/05/09/14303.jpeg like this? And what is the reason for this "\" appearance?
JSON data format is like this, JS in the call is no problem.
But I see the online tutorials are not all "0": Upload/2013/05/09/14303.jpeg like this? And what is the reason for this "\" appearance?
Backslash \ is an escape character
If there is a Chinese will transcode first UrlEncode and then UrlDecode no \ Chinese is ok
It's not a key name, but it doesn't, does it?
JS array of syntax and PHP still have a certain difference, not the key name = "Key value, but with, separated
var ar=["Upload\/2013\/05\/09\/14303.jpeg", "Upload\/2013\/05\/09\/14300.jpeg", "Upload\/2013\/05\/09\/148.jpeg", "Upload\/2013\/05\/09\/187.jpeg", "Upload\/2013\/05\/09\/14296.jpeg", "upload\/2013\/05\/09\/203.jpeg";
This ar[0] is upload/2013/05/09/14303.jpeg.
\ is to escape/use, more than/and * () and other symbols are added in front of your output, because they are more special
If the key name is a number, it is automatically hidden