Hello,
I have the local file path as c:\new folder\pdf\today\k.pdf I want to replace the c:\ with file:\\c|
I tried str_replace('','',) but I get error due to the slash, no stripslash will not work.
Thanks Jean
Hello,
I have the local file path as c:\new folder\pdf\today\k.pdf I want to replace the c:\ with file:\\c|
I tried str_replace('','',) but I get error due to the slash, no stripslash will not work.
Thanks Jean
Try:
$string = 'c:\new folder\pdf\hello.pdf';
$new_str = str_replace("c:\\", "file:\\\\\\c|", $string);
echo $new_str;
Result:
file:\\\c|new folder\pdf\hello.pdf
You can do this:
<?php
$a = 'c:\new folder\pdf\today\k.pdf';
$a = str_replace('c:\\','file:\\\\\\c|',$a);
var_dump($a); // print string(36) "file:\\\c|new folder\pdf\today\k.pdf"
?>
Isn't c:\new folder\pdf\today\k.pdf to file:///c|new folder/pdf/today/k.pdf?
If so, following will work, without regex
$x='c:\new folder\pdf\today\k.pdf';
$x='file:///'.str_replace('\\','/',str_replace(':\\','|',$x));
file:///c|new folder/pdf/today/k.pdf will return