HELP WITH PREG_REPLACE!

Hi,
I have variable with path ex: $var1=C:\Windows\Tools
But i need have $var2 with C:\Windows, I need that $var2 contains the same that $var1 but without last (a-z)\ item.

Another example:
$var1=C:\Windows\Tools\Help
$var2 should be = C:\Windows\Tools

I Need this with preg_replace… I have spended many hours and its impossible!!
Thanks :frowning:

Hi,
I have variable with path ex: $var1=C:\Windows\Tools
But i need have $var2 with C:\Windows, I need that $var2 contains the same that $var1 but without last (a-z)\ item.

Another example:
$var1=C:\Windows\Tools\Help
$var2 should be = C:\Windows\Tools

I Need this with preg_replace… I have spended many hours and its impossible!!
Thanks :frowning:

Just use PHP’s “dirname” function…

$var1=“C:\Windows\Tools”;
$var2=dirname($var1);

And, please do not double-post in different areas. Hope this works…

ErnieAlex…
Sorry for double-post but i spent Hours with this f**king problem…
I dont have words to you… it works… im excited!
Really really really thx…

Glad it worked for you… Come back with any other questions… CYA in the bitstream…

Sponsor our Newsletter | Privacy Policy | Terms of Service