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: [opensuse] Back to the basics (bash)
    ... $ echo ... Globbing only expands to existing files that match the pattern, ... or substitution occurs and you get the literal string. ... They both can, at least on linux, so these commands would work. ...
    (SuSE)
  • Re: [opensuse] Back to the basics (bash)
    ... $ echo ... Globbing only expands to existing files that match the pattern, ... or substitution occurs and you get the literal string. ... They both can, at least on linux, so these commands would work. ...
    (SuSE)
  • 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)