Web Hosting Talk







View Full Version : Looking for a PHP Function - Search String and


lilnomad
12-15-2006, 07:05 PM
Hello, I am looking for a PHP function hat can search a string, looking for a character. Once it has spot the character it displays everything prior to that character. Does anyone know of a function that can do this? I've looked on PHP.net but just couldn't find one.

cywkevin
12-15-2006, 07:10 PM
you might be able to tweak something like http://us3.php.net/manual/en/function.strrchr.php to work.

SpeedEXEC
12-15-2006, 07:12 PM
quick attempt:

$var = substr($string, 0, strpos($string, 'c'));

Not at home so I can't really test it, but I think that'll work. :)

Good luck bud, hope I helped.

lilnomad
12-15-2006, 07:18 PM
Thank you RefreshNet, really appericate it.

SpeedEXEC
12-15-2006, 11:08 PM
Not a problem, I try to help when I can. Have a good night bud.