Hi
I need to test if a certain character exists in a string, like spaces commas dots slashes etc
how do i do that in php
its basically the equivalent of javascript for indexOf() method
Thanks
how do you test is a character exists in a string
Moderator: General Moderators
-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
Re: how do you test is a character exists in a string
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
Re: how do you test is a character exists in a string
hey Thanks man.
What's up with this warning
What's up with this warning
so does it return false? or something else? because if it doesnt return false you can't use "!" can you ?Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "".
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: how do you test is a character exists in a string
Here's what the warning means: PHP is loosely typed, which means that 0 == FALSE. For strpos, this can be troublesome, since if you say if(strpos(..)) and it returns 0, the character DOES exist, but the if will evaluate as FALSE. To correctly check for it, state strpos(..) !== FALSE (notice the double equality).
-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
Re: how do you test is a character exists in a string
hey thanks man, i appreciate the explanation !