php - 正则表达式以匹配以...开头的内容
I am terribly sorry but the array looks like this:
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
)
and so on...
When i try to replace for example msie6.0
and msie7.0
with InternetExplorer
and add it occurence :
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]);
it not match the perfect as i want. any solution for that ? in order to have :
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
)
我非常抱歉,但数组看起来像这样: p>
数组
(
[1] =>数组
(
[0] => msie6.0
[1] => 7
)
[2] => 数组
(
[0] => safari5.0.3
[1] => 5
)
[3] =>数组
(
[0] => chrome18 .0.1025.308
[1] => 1
)
[4] =>数组
(
[0] => firefox20.0
[1] => 4
)
[5] =>数组
(
[0] => msie7.0
[1] => 915
)
code> pre>
依此类推...
当我尝试用 InternetExplorer code>替换示例 msie6.0 code>和 msie7.0 code>时 添加它出现: p>
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]);
nn不匹配 他完美如我所愿。 任何解决方案?
为了拥有: p>
数组
(
[1] =>数组
(
[0] => InternetExplorer
[1] => 922
)
[2] =>数组
(
[0] => safari5.0.3
[1] => 5
)\ n
[3] =>数组
(
[0] => chrome18.0.1025.308
[1] => 1
)
[4] =>数组\ n(
[0] => firefox20.0
[1] => 4
)
code> pre>
div>