我想要做的事,如:如何从给定的HTML标记中提取特定的子字符串,但不知道其长度?
<?php
$text = "<font style='color: #fff'>";
$replaceandshow = str_replace("<font style=\"?\">", "the font style is ?", $text);
echo $replaceandshow;
?>
例如,?是颜色:#fff,但我希望PHP能够自己追踪它,是否可能+如果可能的话,我该怎么做?
P.S:有人给了我一个代码,但它现在正在工作,它为我显示一个白页。
<?php
$colorstring = "<font style='#fff'>";
$searchcolor = preg_replace('[a-fA-F0-9]{3,6}','[font style=$1]Test[/font]',$colorstring);
echo $searchcolor;
感谢您的帮助。
非常感谢。 – 2012-08-09 18:26:21