- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$input =
'
input {
redis {
host => "192.168.2.17"
type => "nginx access"
data_type => "list"
key => "nginx access"
password => "v5XBbZHcbaKFQr3kRFLqjZV5"
}
redis {
host => "192.168.1.33"
type => "nginx access"
data_type => "list"
key => "nginx access"
password => "v5XBbZHcbaKFQr3kRFLqjZV5"
}
}
input {
redis {
host => "192.168.2.17"
type => "nginx access"
data_type => "list"
key => "nginx access"
password => "v5XBbZHcbaKFQr3kRFLqjZV5"
}
redis {
host => "192.168.1.33"
type => "nginx access"
data_type => "list"
key => "nginx access"
password => "v5XBbZHcbaKFQr3kRFLqjZV5"
}
}
';
preg_match_all('~\{(?:[^{}]|(?R))*\}~', $input, $sectors);
print_r($sectors);