高亮显示一个字符串在另一个字符串中的部分 PHP中如何高亮显示一个字符串在另一个字符串中的部分。比如一个字符串为:北京欢迎你!,另一个字符串为:北京。那么高亮显示后的结果为:北京欢迎你! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str = '北京欢迎你!';$find= '北京';$color='red';str_replace($find, "<font color={$color}>{$find}</font>", $str); <?php$str="北京欢迎你";$find="北京";$replace="<span style=\"color:red\">".$find."</span>";echo str_replace($find,$replace,$str);?> <html><head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /></head><body></body></html><?php $str="北京欢迎你"; $find="北京"; $result=str_replace($find,"<font color='red'>$find</font>",$str); echo "$result";?> UTF-8 转 GBK/GB2312 乱码问题~ 一个AJAX和PHP问题求解 一个MYSQL 查询时间段的问题 php 如何实现表单的二次提交 如何写用phpmailer类发送邮件的代码? 这个问题已经困饶我两天了...大家帮帮忙!(在线等) 第一使用phpmyadmin导入CSV文件摁是不成功。。。。 php面相对象会员系统php与Html分离 请问WEB程序如何实现打印票据? 拙劣的PHP,都来讨论下 php 找人修改小程序(有偿) php和js查询交互的问题
$find= '北京';
$color='red';
str_replace($find, "<font color={$color}>{$find}</font>", $str);
<?php
$str="北京欢迎你";
$find="北京";
$replace="<span style=\"color:red\">".$find."</span>";
echo str_replace($find,$replace,$str);
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body></body>
</html>
<?php
$str="北京欢迎你";
$find="北京";
$result=str_replace($find,"<font color='red'>$find</font>",$str);
echo "$result";
?>