PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE Fruits (`word` varchar(64), `replace` varchar(64)); INSERT INTO Fruits VALUES ('apple', 'banana'), ('orange', 'pear');
Copy Clear
Copy Format Clear
<?php function replaceString ($content){ $Fruits = $mysqli->query("SELECT * FROM Fruits ORDER BY id DESC"); while($row = mysqli_fetch_array($Fruits))){ $content = str_replace($row['word'], $row['replace'], $content); } return $content; } $string = 'An apple better then sugar, but orange not'; echo replaceString ($string);
Show:  
Copy Clear