•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,596 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,679 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 4398 | Replies: 4
![]() |
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation:
Rep Power: 4
Solved Threads: 1
how do I reverse the direction of a slash? I am trying to reverse the slashes in the directory path of a windows system.
I have tried so many things but then when I actually test it to make sure it works, it always fails, so I decided to try it via brute force. Again this fails because of special symbols, take for example:
[PHP]for ($i=0; $i<strlen($file_dir); $i++)
{
if ($file_dir{$i} == "\\")
{
$file_dir{$i} = "/";
}
}[/PHP]
when I finally tried this method it works wonderfully until I hit some special cases like when I have a folder called:
C:\temp\2004
it turns it into (a tab and some weird symbol in there):
C: emp€4
but I really want it to look like:
C:/temp/2004
I have tried so many things but then when I actually test it to make sure it works, it always fails, so I decided to try it via brute force. Again this fails because of special symbols, take for example:
[PHP]for ($i=0; $i<strlen($file_dir); $i++)
{
if ($file_dir{$i} == "\\")
{
$file_dir{$i} = "/";
}
}[/PHP]
when I finally tried this method it works wonderfully until I hit some special cases like when I have a folder called:
C:\temp\2004
it turns it into (a tab and some weird symbol in there):
C: emp€4
but I really want it to look like:
C:/temp/2004
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
You may want to use addslashes and stripslashes functions.
For example: $file_dir = addsashes($file_dir);
so you will now get symbols (\t is tab, \n is new line etc)
You may try str_replace function to change the direction of the slashes.
.
For example: $file_dir = addsashes($file_dir);
so you will now get symbols (\t is tab, \n is new line etc)
You may try str_replace function to change the direction of the slashes.
.
Ecommerce-Web-Store.com Building Your e-Business.
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
Then str_replace function is the solution... I guess
Ecommerce-Web-Store.com Building Your e-Business.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- plz urgent urgent urgent help plz (PHP)
- another newbie with alot of redhat and apache server Q'S (Linux Servers and Apache)
- How to modify/change a logo on a wallpaper? (Graphics and Multimedia)
- Technology Change (IT Careers and Business)
- Change in Certification Policy NT vs 2000 (Windows NT / 2000 / XP / 2003)
Other Threads in the PHP Forum
- Previous Thread: PHP 5.0.5 Released - Vulnerability Fixes
- Next Thread: PHP .htaccess form


Linear Mode