fork download
  1. <?php
  2. $input = '{html owner="html" placeholder="content"}{html owner="html" placeholder="after_content"}';
  3.  
  4. $callback = function($matches){
  5. echo "Tag name: {$matches['name']}\n";
  6. if (preg_match_all('#(?P<attributes>[\w-]+)\s*=\s*"(?P<values>[^\"]+)"#iu', $matches['attributes'], $attributes)) {
  7. var_dump(array_combine($attributes['attributes'], $attributes['values']));
  8. }
  9. };
  10.  
  11. '#{
  12. (?P<name>[\w-]+)\s+
  13. (?P<attributes>[^{}]+)\s*
  14. }
  15. #iux',
  16. $callback,
  17. $input
  18. );
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
Tag name: html
array(2) {
  ["owner"]=>
  string(4) "html"
  ["placeholder"]=>
  string(7) "content"
}
Tag name: html
array(2) {
  ["owner"]=>
  string(4) "html"
  ["placeholder"]=>
  string(13) "after_content"
}