replace special characters
| From: | Frank Arensmeier | Date: | Thu, 24 Feb 2005 08:14:32 +0000 |
| Subject: | replace special characters | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-209317@lists.php.net to get a copy of this message | ||
Hello everybody!
I was wondering if you could help me with a little problem I ran into some days ago.
In my database I have some information about file paths. Originally, those paths come from a Windows Excel spreadsheet and look like "..\1 PDF Filer\65051.PDF". In my PHP code I try to do two things:
1) replace ".." with a string like "file://server/folder"
2) replace all "\" characters with "/".
The PHP code looks something like:
$path_to_file = "..\1 PDF Filer\65051.PDF";
$things_to_look_for = array("..", "\");
$things_to_replace_with = array("file://server/folder", "/");
$link = str_replace($things_to_look_for, $things_to_replace_with, $path_to_file);
The big problem is the character "\" which, if I got it right, in UNICODE is used for things like expressing line breaks ('\n' or something like this). The code above is resulting in the following error massage: "Parse error: parse error, expecting `')'' in /xxx/xxx/xxx/TMPz06yoces6o.php on line 2."
Is there a simple solution for this problem?
Regards,
Frank