我有一个字符串,像这样:
HCl3C24
我希望在php中拆分这个字符串,就像这样
array(0 => H , 1 => Cl, 2 => 3 , 3 => C, 4 => 24)
我现在正在尝试:
$matches = array();
$string = "HCl4";
preg_match_all('/([0-9]+|[a-zA-Z]+)/',$string,$matches);
print_r($matches[0]);
对于数字而言是有效的,但对于字符无效。 有人可以在这里帮助我吗?
[ "H", "Cl", 3, "C", 24 ]
吗? - Halcyon