so i'm trying to fetch everything within <php> and </php> tags in my string, and return each instance of a match. currently my string has two sets of <php> tags. the return i'm getting is everything between the first opening tag and the last opening tag. but that's not what i need.
here be my code:
here's the return:
Array
(
[0] => Array
(
[0] => <php>this</php> and <php>that</php>
)
[1] => Array
(
[0] => this</php> and <php>that
)
)
ideally i'd like to have in my $matches array the values this and that
i'm not familiar with PHP's regex functions, and even less familiar with regex patterns. any help would be great, thanks.
here be my code:
PHP:
$pattern = "/<php>(.*)<\/php>/i";
$str = "display <php>this</php> and <php>that</php>, okay?";
$match = preg_match_all($pattern, $str, $matches, PREG_PATTERN_ORDER);
print_r($matches);
here's the return:
Array
(
[0] => Array
(
[0] => <php>this</php> and <php>that</php>
)
[1] => Array
(
[0] => this</php> and <php>that
)
)
ideally i'd like to have in my $matches array the values this and that
i'm not familiar with PHP's regex functions, and even less familiar with regex patterns. any help would be great, thanks.