Php 如何将字符串中的特定字符用<;strong>;通过preg_替换?

Php 如何将字符串中的特定字符用<;strong>;通过preg_替换?,php,string,Php,String,目前我有一个没有HTML格式的字符串,下面是一个示例: Tue 28 Apr 2015: 10.30am: This is the name of the event. 使用PHP,我需要将所有显示在最后一个冒号前面的内容加粗,即将出现在最后一个:前面的任何内容包装在标记中 开头的strong标记总是出现在开头,所以我需要脚本做的就是在最后的:之后插入标记 以下是所需的输出: <strong>Tue 28 Apr 2015: 10.30am:</strong> This

目前我有一个没有HTML格式的字符串,下面是一个示例:

Tue 28 Apr 2015: 10.30am: This is the name of the event.
使用PHP,我需要将所有显示在最后一个冒号前面的内容加粗,即将出现在最后一个
前面的任何内容包装在
标记中

开头的strong标记总是出现在开头,所以我需要脚本做的就是在最后的
之后插入
标记

以下是所需的输出:

<strong>Tue 28 Apr 2015: 10.30am:</strong> This is the name of the event.
2015年4月28日星期二:上午10:30:这是活动的名称。

您给出的示例不太清楚。您可以通过简单的preg_分割实现所需:

<?php
$myString= "Tue 28 Apr 2015: 10.30am: This is the name of the event.";
$myString2=preg_split("/:/", $myString,1);
$myString3="<strong>" .$myString2[0] . "</strong>" . $myString2[1];
echo $myString3;
?>


请显示示例输入和所需输出。是否将其包装在标记中?