FIRST PROBLEM SOLVED.. NEW PROBLEM - Now it seems that if it finds "use" inside the word because (beca"use") it would replace it, what should i add? to the existing code to fix it? <?php include 'config.php'; include 'connectdb.php'; $text = $_POST["text"]; $query = "SELECT * FROM myqrio"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $oldword = $row['word']; $newword = $row['replacex']; $text = str_replace($oldword, $newword, $text); } echo $text; include 'connectoff.php'; ?> PHP: I was thinking maybe.. add a space infront of the string of $oldword ?
Try this: <?php include 'config.php'; include 'connectdb.php'; $text = $_POST["text"]; $query = "SELECT * FROM myqrio"; $result = mysql_query($query); $SearchWords = array(); $ReplaceWords = array(); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $SearchWords[] = $row['word']; $ReplaceWords[] = $row['replacex']; } $final = str_replace( $SearchWords, $ReplaceWords, $text ); echo $final; include 'connectoff.php'; ?> PHP: Brew
? <?php include 'config.php'; include 'connectdb.php'; $text = $_POST["text"]; $query = "SELECT * FROM myqrio"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $oldword = $row['word']; $newword = $row['replacex']; $text = str_replace($oldword, $newword, $text); } echo $text; include 'connectoff.php'; ?> PHP: