如何使用LOOP循环
我想把这段代码用到模板里去
但是模板中不能用FOR循环,这段代码很有用的,可能对大家也会有点用处。
谁知道怎么用LOOP解决这个问题吗?
<?
$str = '测试字符串123456.789测试9.926字2222符串';
$str1 = preg_match_all('/\d+(\.\d+)?/',$str,$matches);
for($i=0;$i<=$str1-1;$i++)
$a[$i]= $matches[0][$i];
$x0 = str_replace("$a[0]","<font color =red>$a[0]</font>",$str);
$x1 = str_replace("$a[1]","<font color =red>$a[1]</font>",$x0);
$x2 = str_replace("$a[2]","<font color =red>$a[2]</font>",$x1);
echo $x2;
?> |