0

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:

for ($i=0; $i<strlen($file_dir); $i++)
{
	if ($file_dir{$i} == "\\")
	{
		$file_dir{$i} = "/";
	}
}

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

3
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by leelee
0

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.
.

0

all that does is add an escape slash, I didn't want to do that at all. I want to reverse the direction of the slash. I already know about addslashes/stripslashes and magic_quotes and all that jazz... I want to be able to reverse the direction of the slash

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.