chadr-php Posted August 16, 2010 Share Posted August 16, 2010 I want to identify strings with AT&T in them. Can't seem to find the right way to do this due to the &. I am using the strpos function in this manner: if (strpos(($string), 'AT&T')) > 0) I don't need to input or display using http. This is just a php script that I'll run from the command prompt. Thanks. Link to comment https://forums.phpfreaks.com/topic/210875-searching-a-string-for-occurrence-of-att/ Share on other sites More sharing options...
AbraCadaver Posted August 16, 2010 Share Posted August 16, 2010 Assuming that it's really an & and not & then this works: if (strpos($string, 'AT&T') !== false) Not sure why you had all the parentheses in there. Link to comment https://forums.phpfreaks.com/topic/210875-searching-a-string-for-occurrence-of-att/#findComment-1099895 Share on other sites More sharing options...
chadr-php Posted August 16, 2010 Author Share Posted August 16, 2010 Oops, I was checking for > 0 when I really should have checked for !== false. Turns out that AT&T started as position 0 of the string I was using to check the script. Thanks. Link to comment https://forums.phpfreaks.com/topic/210875-searching-a-string-for-occurrence-of-att/#findComment-1099919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.