This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-10-30 15:35:55

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

censoring help

I have a thing in php where I made a censoring list:

Code:

$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)?


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#2 2011-10-30 15:40:21

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Offline

 

#3 2011-10-30 15:41:36

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: censoring help

strtoupper($badWord)==strtoupper($bAdWOrD)

Offline

 

#4 2011-10-30 15:45:33

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: censoring help

Thanks! It never struck me to just make the string lower-case!


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#5 2011-10-30 15:47:38

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: censoring help

WindowsExplorer wrote:

Thanks! It never struck me to just make the string lower-case!

welcome


http://i.imgur.com/zeIZW.png

Offline

 

#6 2011-10-30 16:03:20

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: censoring help

I got it working now  smile


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#7 2011-10-30 16:27:46

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: censoring help

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)


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#8 2011-10-30 16:34:49

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: censoring help

(strcasecmp() doesn't work)


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#9 2011-10-30 17:07:46

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: censoring help

$variable = strtolower('Hello');
edit: whoops if( $variable == strtolower('Hello') ) {stuff}

Last edited by rookwood101 (2011-10-30 17:09:21)


http://i.imgur.com/zeIZW.png

Offline

 

#10 2011-10-30 17:08:54

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: censoring help

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.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#11 2011-10-30 17:13:06

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: censoring help

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.  smile  And if it equals that, use the original variable.

Offline

 

#12 2011-10-30 17:14:18

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: censoring help

rookwood101 wrote:

$variable = strtolower('Hello');
edit: whoops if( $variable == strtolower('Hello') ) {stuff}

I updated my post


http://i.imgur.com/zeIZW.png

Offline

 

Board footer