I have a thing in php where I made a censoring list:
$vowels = array(" ", " ");
$bad = str_replace($vowels, "*", "$stringr");but I was just wondering is there a way to make it not case sensitive for example,
if teh word hello was in the list, and a user entered HElLo it would still replace it with a * (asterick)?
Offline
WindowsExplorer wrote:
Thanks! It never struck me to just make the string lower-case!
welcome
Offline
Ok, this is a pretty basic question, but google doesn't seem to be able to find what I want. I would like to make a string not case sensitive, for example:
$vaiable = Hello;
the code if ($variable == "hello") {} doesn't work in this case, so I was wondering if theres a not_case_sensitive() opertator or somethign similar?
Help appreciated!
Last edited by WindowsExplorer (2011-10-30 16:27:59)
Offline
$variable = strtolower('Hello');
edit: whoops if( $variable == strtolower('Hello') ) {stuff}
Last edited by rookwood101 (2011-10-30 17:09:21)
Offline
rookwood101 wrote:
$variable = strtolower('hello');
no, because I don't want the string to be lowercase, I just want php to detect it as lowercase.
Offline
WindowsExplorer wrote:
rookwood101 wrote:
$variable = strtolower('hello');
no, because I don't want the string to be lowercase, I just want php to detect it as lowercase.
Make an extra variable to change it to lower case for checking.
And if it equals that, use the original variable.
Offline
rookwood101 wrote:
$variable = strtolower('Hello');
edit: whoops if( $variable == strtolower('Hello') ) {stuff}
I updated my post
Offline