PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Thu Jan 18, 2007 5:21 pm
I can use
to return the part after the needle if found. But I want a function that returns everything before the needle.
EG:
Code: Select all
$string = "autoexec.bat";
echo whatFunction(".", $string);
# outputs autoexec.
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Thu Jan 18, 2007 5:42 pm
explode()
preg_split()
split()
all come to mind
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Thu Jan 18, 2007 6:22 pm
preg_split and split and explode? What are you guys thinking
Code: Select all
substr($haystack, 0, strpos($haystack, $needle));
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Thu Jan 18, 2007 6:26 pm
ole wrote: preg_split and split and explode? What are you guys thinking
Code: Select all
substr($haystack, 0, strpos($haystack, $needle));
Did you read my post?