theniteowl
Programmer
Hi All
I need to strip the root folder name and surrounding slashes.
I had thought that specifying the string to remove would do the trick and it seemed to with the code below.
$mypath = "/root/myfolder/file.htm";
$filepath = ltrim( $mypath, "/root/" );
But if the path were this:
$mypath = "/root/rodent/file.htm"
then /root/ro gets stripped and my path ends up:
dent/file.htm.
So apparently it does not match the entire string as a whole but parts of it.
Anyone have a better way to strip the value?
Ultimately the value "/root/" will actually be a variable so the name of the root folder can be set globally elsewhere.
At my age I still learn something new every day, but I forget two others.
I need to strip the root folder name and surrounding slashes.
I had thought that specifying the string to remove would do the trick and it seemed to with the code below.
$mypath = "/root/myfolder/file.htm";
$filepath = ltrim( $mypath, "/root/" );
But if the path were this:
$mypath = "/root/rodent/file.htm"
then /root/ro gets stripped and my path ends up:
dent/file.htm.
So apparently it does not match the entire string as a whole but parts of it.
Anyone have a better way to strip the value?
Ultimately the value "/root/" will actually be a variable so the name of the root folder can be set globally elsewhere.
At my age I still learn something new every day, but I forget two others.