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
.



Relevant Pages

  • Re: set user=%username%
    ... Your most recent feedback confirms that Windows is ... Type this: echo %MyName% ... > usertest=This is a long string. ...
    (microsoft.public.windows.server.general)
  • Re: its not the school home work
    ... I've learned a bit about strong quotes and think I realized when to ... the shell (such as in the $var, but also for the spaces (that ... echo "foo bar" ... you may say that $string does not appear in /list/ context so ...
    (comp.unix.shell)
  • Re: TRUE and FALSE are treated differently
    ... No -- you can't echo a boolean in PHP. ... If you look up the manual on type casting, you'll find that FALSE is cast ... to an empty string, and TRUE is cast to a non-empty string. ...
    (comp.lang.php)
  • Re: TRUE and FALSE are treated differently
    ... No -- you can't echo a boolean in PHP. ... the boolean is implicitly cast to a string. ... If you look up the manual on type casting, you'll find that FALSE is cast to an empty string, and TRUE is cast to a non-empty string. ...
    (comp.lang.php)
  • Re: WEB SITE PROJECT DEPLOYMENT ~ Help please??
    ... ECHO When/If prompted with the question: ... The files are all now sitting on my Server, and when I load my web site, ... An error has occurred while establishing a connection to the server. ... The connection string specifies a local Sql Server Express instance using ...
    (microsoft.public.dotnet.framework.aspnet)