$var = '<lang test=<php>string</php>><lang test2=before<php>inside</php>>'.
'<lang test3=THIRD_WITHOUT_PHP_TAGS><lang test4>';
if (preg_match_all('#<lang (.*?)>#', $var, $gg))
{
var_dump($gg[1]);
}
I get the dump:
array(2) {
[0]=>
string(9) "test=<php"
[1]=>
string(16) "test2=before<php"
}
But I want to get :
test=<php>string</php>
and
test2=before<php>inside</php>
and
test3=THIRD_WITHOUT_PHP_TAGS
and
test4
How to do it?
EDIT: I CHANGE THE $var AND ADD third expression
EDIT 2: ADEED the fourth expression without "="
</php>always at the end (</php>>) ?$var = '<lang test=[php]string[/php]><lang test2=before[php]inside[/php]>';and you whont need to modify you're regexp , or you could skip the first two ocurences of '>' but then what if you pass$var = '<lang test=some other test>without any <php> tags ? somebody else better than me will figure out an answer without the need to change the php tags