Php outputs the http address in the database and the format changes. how can this problem be solved? I know that we can use str_replace to replace \ With '', but this will also cause problems, if the data in json format contains Chinese characters, the \ asd5 of Chinese characters will be changed to asd5 .. Is there any other way to solve this problem?
Reply to discussion (solution)
Why/becomes \/. have you found the reason?
/Is not a special character. without a php function, it will be escaped (except preg_quote)
You can use str_replace to replace \/'/'....
Why/becomes \/. have you found the reason?
/Is not a special character. without a php function, it will be escaped (except preg_quote)
I don't know why .. Store it in the database. This is the case ..
You didn't do it. that's impossible.
You didn't do it. that's impossible.
function get_js_array($sql){$result = @mysql_query($sql) or die(mysql_error());$arr = array();while($row = @mysql_fetch_array($result, MYSQL_ASSOC)){$arr[] = $row; }$js = json_encode($arr);mysql_free_result($result);return $js;}
This is my execution statement .. I don't know. Is there a problem?
Oh! This is the case.
$js = json_encode($arr, JSON_UNESCAPED_SLASHES);
Oh! This is the case.
$js = json_encode($arr, JSON_UNESCAPED_SLASHES);
Perfect solution .. Like!