Re: replace single slash with double slash



dkirkdrei@xxxxxxxxx wrote:

the code:

<?
$var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf";
echo strtr($var, array('\\' => '\\\\'));
?>

produces this:

\\wusais\\Intranets\\Intranets\\fpdb\\pdf\\weinig05882.pdf

close but the end is still killing me...


If the string is coming from DB as you have said, you shouldn't be assigning it to $var, but fetch it from the database instead, like this:

$rc = mysql_query("SELECT .....");
$row = mysql_fetch_array($rc);
$var = $row['fieldname'];

echo strtr($var, array('\\' => '\\\\'));


--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
.