Let's say this is my variable:
$path="/home/username/a/b/c/1/2/3";
How do I remove the value between the 2nd and 3rd slashes (in this case, the username)? I just want to get the value by itself without the slashes on either side.
Thanks in advance.
Depends a little on how much variation you have in the string. But if it is alway between the 2nd and 3rd slashe you can do an [man]explode()[/man] by slash. Then you have an array holding all the parts between slashes.
otherwise you have to work with regular expresssions, which is quite a hassle if you are not familiar with them.
J.
Thanks, I got it. Here's the code for anyone looking to do the same thing:
$path="/home/username/a/b/c/1/2/3"; $count=0; $explode_path=explode('/',$path); foreach($explode_path as $path_section) { if ($count == 2) { echo "$path_section<BR>"; } //if $count++; } //foreach