Thread: Search string
View Single Post
 
Old June 2nd, 2005, 01:27 AM
anshul anshul is offline
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

True.

echo strpos($string, "BlackBerry"); // displays '0'
echo strpos($string, "BBlackBerry"); // displays 'nothing', NULL?

I tried to comapre it with 'NULL', still, it not yields!!

so,
Quote:
quote:if(gettype(strpos($string, "BlackBerry"))=="integer")
    echo "Blackberry web browser detected";

is fine as strpos() returns string position in integer, and NULL? when it not finds..

Alternatively, you may use preg_match() or preg_match_all() functions for absolute-n-powerful matching; these are PHP functions supporting PCRE. It'll take you a while to learn regex ( if you don't know ), but it's a worthy stuff, to invest time.