chimsik chimsik - 1 year ago 66
MySQL Question

In PHP code, how can I remove newlines

In my PHP code

$sql = "SELECT a.SEQ, a.DPCODE, a.SUBJECT, CONCAT_WS('~',a.SDATE, a.EDATE) AS SDATE, b.content, concat(replace(c.filepath,'E:/WWW',''),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";

, it returns:

result in explorer

I want to remove '\'.

Answer Source

You can use str_replace

$variable = 'http:\/\/\/\/upload\/pj\/PJ_EXHIBIT\/1480308974751289.jpg';
$new = str_replace('\\', '', $variable);
echo $new;

Or you can use preg_replace

$variable = 'http:\/\/\/\/upload\/pj\/PJ_EXHIBIT\/1480308974751289.jpg';
$new = preg_replace("/\\\/", '', $variable);
echo $new;    


More informations can be found below:

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