views:

38

answers:

1

Hello, 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_all 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.

+1  A: 

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) ""
  }
}
M42
if I do that it doesn't find things anymore. If I escape them once it's just the same. I search for <??translate bla??> or <?? translate bla?? >
yajRs
@yajRs: i've updated my answer.
M42
Omg, im stupid, <?? tags dont show in firefox. Thats why i thought it would not work, thanky you!
yajRs