【发布时间】:2016-01-03 08:19:44
【问题描述】:
我想为字符串中的每个数字下标。
例如:
$str = '1Department of Chemistry, College of 2Education for Pure Science';
我想要的输出:
<sub>1</sub>Department of Chemistry, College of <sub>2<sub>Education for Pure Science
我从一个字符串中提取了所有数字:
//digits from string
preg_match_all('!\d+!', $str, $matches);
print_r($matches);
但是如何将下标效果应用于数字和打印字符串?
【问题讨论】: