3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = " /\[ (?:block:(?<block>piechart)) (?: (?:\s+value:(?<value>[0-9]+)) | (?:\s+stroke:(?<stroke>[0-9]+)) | (?:\s+angle:(?<angle>[0-9]+)) | (?:\s+colorset:(?<colorset>reds|yellows|blues)) )* \]/xumi"; $subject = "here is a block to be replaced [block:piechart value:25 angle:0] [block] and another one [block:piechart colorset:reds value:20]"; preg_replace_callback($pattern, 'callbackFunction', $subject, -1, $count, PREG_UNMATCHED_AS_NULL); function callbackFunction($matches) { var_dump(array_filter($matches, function ($v) { return !is_null($v); })); // process matched values, return some replacement... $replacement = "..."; return $replacement; };

preferences:
25.4 ms | 406 KiB | 5 Q