【发布时间】:2011-04-01 14:00:13
【问题描述】:
我想用 bold 中的 $sq 中的单词呼应 $desc。这是我的代码的样子:
<?php
$desc = "This a sentence witch contains 4 words on is Hello the other is moto the third is hoto and finally but not least nono.";
$sq = "Hello moto hoto nono";
$pieces = explode(" ", $sq);
foreach (array($pieces[0], $pieces[1],$pieces[2],$pieces[3],$pieces[4]) as $item)
$descr = str_replace($item, "<b>".$item."</b>", $desc);
echo $descr;
?>
谢谢
【问题讨论】:
-
“这句话”忘了是
标签: php arrays replace foreach explode