如何删除 preg_match_all 结果中无用的数组项?
正则表达式中的某些项目对我没有用,我不希望它们显示在我的 $result 数组中,我该怎么做?我remmbered preg_match 可以在得到结果时删除无用的“(xxx)”,但我不记得现在如何编码
<?php
$url='http://www.new_pm.com/fr/lookbook/2.html';
preg_match_all('@([a-z]{2})?(lookbook)/?(\d+)?(\.html)?@',$url,$result);
print_r($result);
/* -------
Array
(
[0] => Array
(
[0] => lookbook/2.html
)
[1] => Array // I don't want $result has this item
(
[0] =>
)
[2] => Array
(
[0] => lookbook
)
[3] => Array
(
[0] => 2
)
[4] => Array // I don't want $result has this item
(
[0] => .html
)
)
------- */
?>