[PHP] Best way to check for some certain text in a string
I want to find a certain text in a string and i want it to return me a boolean. What is the best thing to do this? a) ereg(search for this, $string);// returns int(1) if true, bool(false) if not b) strpos($nav-userAgent, search for this) 0// gives me a boolean directly Any tips of which one I should use? /José Jeria -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Best way to check for some certain text in a string
Bogdan Stancescu [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... If you don't need regexps, use strpos. Make sure you read the Can you give me any particular reason why strpos is better? documentation though - if $nav-userAgent starts with search for this, your code will return false. Yeah, that was a typo when i copy and pasted. Bogdan José Jeria wrote: I want to find a certain text in a string and i want it to return me a boolean. What is the best thing to do this? a) ereg(search for this, $string);// returns int(1) if true, bool(false) if not b) strpos($nav-userAgent, search for this) 0// gives me a boolean directly Any tips of which one I should use? /José Jeria -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Checkbox question
I have a page with a checkbox, when i submit to the next page the variable $whatever (the checkboxes name.) will be On if its checked, and it will be undefined if its not checked. Shouldn't it be a empty string? and not undefined? /José -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checkbox question
Hmmm, then the book Beginning PHP from Wrox is wrong... /J Jason Wong wrote: On Friday 16 August 2002 17:54, José Jeria wrote: I have a page with a checkbox, when i submit to the next page the variable $whatever (the checkboxes name.) will be On if its checked, and it will be undefined if its not checked. Shouldn't it be a empty string? and not undefined? That is how it works. If it's not checked it does not get defined. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php