很對不起啓動,但該陣列是這樣的:PHP - 正則表達式匹配成才與
Array
(
[1] => Array
(
[0] => msie6.0
[1] => 7
)
[2] => Array
(
[0] => safari5.0.3
[1] => 5
)
[3] => Array
(
[0] => chrome18.0.1025.308
[1] => 1
)
[4] => Array
(
[0] => firefox20.0
[1] => 4
)
[5] => Array
(
[0] => msie7.0
[1] => 915
)
等等... 當我試圖取代例如msie6.0
和msie7.0
與InternetExplorer
並添加它:
preg_match("/#^msie(.*)$#i/is", $results, $matches);
$test = $matches[0] ;
print_array($test);
$results["#^startText(.*)$#i"] = $results['InternetExplorer'];
print_array($results);
unset($results["/#^msie(.*)$#i/is]);
它不符合我想要的完美。任何解決方案? 爲了有:
Array
(
[1] => Array
(
[0] => InternetExplorer
[1] => 922
)
[2] => Array
(
[0] => safari5.0.3
[1] => 5
)
[3] => Array
(
[0] => chrome18.0.1025.308
[1] => 1
)
[4] => Array
(
[0] => firefox20.0
[1] => 4
)
你想用「InternetExplorer」或整個密鑰替換一部分? – Rikesh
我想要替換以'msie'開始的每一個密鑰,並將它的值加上'InternetExplorer'中的所有值的總和。 – SpencerX