Reputation: 59
I have a sip.conf file that contains data like that :
#<COMPTE
[6007](template)
fullname = ggg
username = ggg
secret = nana
COMPTE>#
#<COMPTE
[6008](template)
fullname = dada
username = dada
secret = dada
COMPTE>#
I have created a method using java :
Matcher matcher = Pattern.compile("(?m)^#<COMPTE.*?COMPTE>#",Pattern.MULTILINE | Pattern.DOTALL).matcher(chaine);
while (matcher.find()) {
comptes=matcher.group();
}
I want something like that in PHP I have tried many things but it doesn't seems to work, any help ?
Upvotes: 0
Views: 41
Reputation: 663
I think this is what you're looking for.
$chaine = <<<EOT
#<COMPTE
[6007](template)
fullname = ggg
username = ggg
secret = nana
COMPTE>#
#<COMPTE
[6008](template)
fullname = dada
username = dada
secret = dada
COMPTE>#
EOT;
$pattern = "/COMPTE(.*?)COMPTE/sm"; // s = dotall, m = multiline
preg_match_all($pattern, $chaine, $matches);
print_r($matches);
Upvotes: 1