xyn Posted November 27, 2006 Share Posted November 27, 2006 Yo.right here's the scenario, basically I wanted to enter all 'bad words'into my database ONCE, in LOWERCASE (done) but how can i SETthe field to LOWERCASE, Replace all nescassary fields, then removethe LOWERCASE?My codefunction FilterWords($w1){ $sql = mysql_query("SELECT * FROM filter"); $words = array(); $replace = array(); while ($x = mysql_fetch_array($sql)) { $words[] = $x['badword']; $replace[] = $x['replace']; } $return = str_replace($words, $replace, $w1); return $return;}used as... FilterWords($_POST[field]); Link to comment https://forums.phpfreaks.com/topic/28676-solved-language-filter/ Share on other sites More sharing options...
alpine Posted November 27, 2006 Share Posted November 27, 2006 Look at str_ireplace instead, the non case sensitive version of str_replace:http://no2.php.net/manual/en/function.str-ireplace.php*EDIT: PHP5 only, look at some of the contributions in the manual for similar behaviour under other php versions Link to comment https://forums.phpfreaks.com/topic/28676-solved-language-filter/#findComment-131227 Share on other sites More sharing options...
xyn Posted November 28, 2006 Author Share Posted November 28, 2006 Thanks :] all i needed to do was add 'i' on replace() on myfunction... which has worked. Link to comment https://forums.phpfreaks.com/topic/28676-solved-language-filter/#findComment-131615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.