我有一句话:
“如何从mysql数据库中查找和替换文本中的单词?”
和 MySQL 表 words,有 3 列 id,word 和 replaceWord。 我有超过 4000 个单词的数据库。
表格:
id word replaceWord
1 text sentence
2 word letter
3 mysql MySQL
4 .. ...
5 .. ...
6 .. ...
结果:
“如何从MySQL数据库中查找和替换句子中的字母?”
我知道如何在没有数据库的情况下执行此操作,但我需要数据库。
<?php
$text="How to find and replace word in text from mysql database?";
$replaceWord=array( "text" => "sentence", "word" => "letter", "mysql" => "MySQL");
echo strtr($tekst, $replaceWord);
?>
最佳答案
update YourTable, Words
set YourTable.YourColumn = replace(YourTable.YourColumn, Words.word, Words.replaceWord)
关于php - 如何查找和替换 MySQL 文本字段中的整个单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4829281/