View Single Post
Old 01-28-2008, 01:29 PM   #1 (permalink)
Gareth
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default Function with Mysql

Hey guys

I am a real newbie at functions; so I would like some help :)

Basically I have a static version sorted:

PHP Code:
<?php 
function cuss_filter($string) { 
    
$bad_words = array("bad""language"); 
    foreach (
$bad_words as $cuss) { 
        if (
stristr(trim($string),$cuss)) { 
            
$length strlen($cuss); 
            for (
$i 1$i <= $length$i++) { 
                
$stars .= "*"
            } 
            
$string eregi_replace($cuss,$stars,trim($string)); 
            
$stars ""
        } 
    } 
    return 
$string

?>


<?php
    
    $content 
"I have bad language";
    echo 
cuss_filter($content);

?>
which works fine, but instead of having to write the bad words into the $bad_words, I would like to select the bad words from a database (table name sbb_badwords). I would be able to do this outside of the function, easily, with mysql_fetch_array, but how would i do this in the function?

Gareth
Gareth is offline  
Reply With Quote