在PHP代码中,如何删除换行符

时间:2016-11-28 11:02:44

标签: php mysql replace

在我的PHP代码中

$sql = "SELECT a.SEQ, a.DPCODE, a.SUBJECT, CONCAT_WS('~',a.SDATE, a.EDATE) AS SDATE, b.content, concat(replace(c.filepath,'E:/WWW','http://myhome.com/'),c.filelocalnm) as filename";
$sql .= " FROM PJ_EXHIBIT a LEFT JOIN collection.exhibit b ON a.SEQ=b.seqno LEFT JOIN sy_file c ON a.attach_file = c.SEQ";

使用json_encode,它会返回:

result in explorer

我想删除' \'。

1 个答案:

答案 0 :(得分:0)

您可以使用str_replace

<?php
$variable = 'http:\/\/comin.com:8990\/\/upload\/pj\/PJ_EXHIBIT\/1480308974751289.jpg';
$new = str_replace('\\', '', $variable);
echo $new;
?>

或者您可以使用preg_replace

<?php
$variable = 'http:\/\/comin.com:8990\/\/upload\/pj\/PJ_EXHIBIT\/1480308974751289.jpg';
$new = preg_replace("/\\\/", '', $variable);
echo $new;    
?>

<强>手册

更多信息可以在下面找到: