开发者

preg_match_all doesn't reply matches array?

I have a problem with preg_match_all. While preg_match does reply the whole match as the first element of the array, preg_match_al开发者_如何转开发l doesn't - the first array is empty. At least with the pattern I chose (havn't tried others since it's the one I need) it doesn't work. Here is my code:

preg_match_all("/<\?\?(\t| )?translate(\t| )?;(\t| )?(.*)(\t| )?\?\?>/U", $file, $translate_info);

The pattern itself is working and producing subpattern matches.


Updated according to new given details :

$file = '<?? translate ; foo bar??>';
$res = preg_match_all('/<\?\?(\t| )?translate(\t| )?;(\t| )?(.*)(\t| )?\?\?>/U', $file, $translate_info);
echo "res='$res'\n";
var_dump($translate_info);

Works for me, it gives :

res='1'
array(6) {
  [0]=>
  array(1) {
    [0]=>
    string(26) "<?? translate ; foo bar??>"
  }
  [1]=>
  array(1) {
    [0]=>
    string(1) " "
  }
  [2]=>
  array(1) {
    [0]=>
    string(1) " "
  }
  [3]=>
  array(1) {
    [0]=>
    string(0) ""
  }
  [4]=>
  array(1) {
    [0]=>
    string(8) " foo bar"
  }
  [5]=>
  array(1) {
    [0]=>
    string(0) ""
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜