madrazel Posted April 23, 2007 Share Posted April 23, 2007 given is string: http://www.server.com/dir/dir2/dir3/file.html or [email protected] and result should be: http://www.server.com/dir/dir2/dir3/ or myname@ how to make it *really fast* without strrev and strstr ? Link to comment https://forums.phpfreaks.com/topic/48358-what-is-the-fastest-method-to-extract-directory-from-url/ Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 i guess without strrev and strstr, this will work <?php #$subject = "http://www.server.com/dir/dir2/dir3/file.html"; $subject = "[email protected]"; $result = eregi_replace('(.*@).*', '\\1', $subject); $result = eregi_replace('(.*\\/)(.*)[^\\/]+$', '\\1', $result); echo "$result<br />"; ?> Please note i am still learning eregi so am use them when i can, so this was kinda pratice for me Link to comment https://forums.phpfreaks.com/topic/48358-what-is-the-fastest-method-to-extract-directory-from-url/#findComment-236445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.