Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图将一个字符串拆分成一个数组,这样如果字符串是 z10k4m42它就会变成
z10k4m42
array('z' => 10, 'k' => 4, 'm' => 42)
这可能吗?
试试下面的:
preg_match_all('/([a-z]+)(\d+)/', 'z10k4m42', $matches); $ret = array_combine($matches[1], $matches[2]);