Ashok Gujjar Ashok Gujjar - 2 years ago 84
SQL Question

how to reverse back of mysql_escape_string function in php?

I am storing

"id": "a34da9b020ec86dc5a7832620082ed5d",
"type": "img",
"name": "1458561170282.jpg",
"mime_type": "image/jpg",
"path": "",
"thumb": "",
"short_link": ""

in a MySQL database using

When I retrieve the data I have the following output:

[\n {\n \"short_link\" : \"http:\\\\/\\\\/\\\\/img1085805\",\n \"id\" : \"ca96c55e1aa76fbca17ee08cad7e5a15\",\n \"thumb\" : \"http:\\\\/\\\\/\\\\/boxdata\\\\/asset22114\\\\/images\\\\/thumb__chat_files_41.jpg?r=160421015318\",\n \"type\" : \"img\",\n \"path\" : \"http:\\\\/\\\\/\\\\/boxdata\\\\/asset22114\\\\/images\\\\/chat_files_41.jpg?r=160421015318\",\n \"name\" : \"chat_files_41.jpg\",\n \"mime_type\" : \"image\\\\/jpg\"\n }\n]

How can I convert my data back in the initial format?

Answer Source

Hope this helps

$str='[\n {\n "short_link" : "http:\/\/\/img1085805",
\n "id" : "ca96c55e1aa76fbca17ee08cad7e5a15",
\n "thumb" : "http:\/\/\/boxdata\/asset22114\/images\/thumb__chat_files_41.jpg?r=160421015318",
\n "type" : "img",\n "path" : "http:\/\/\/boxdata\/asset22114\/images\/chat_files_41.jpg?r=160421015318",
\n "name" : "chat_files_41.jpg",\n "mime_type" : "image\/jpg"\n }\n]';
echo stripslashes(str_replace('\n','',$str));

check screenshot enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download