<?php $string = 'sample {} test {} string {}'; $count = 0; echo preg_replace_callback("~{}~", function($m) use (&$count) { return '(' . $count++ . ')'; }, $string);
You have javascript disabled. You will not be able to edit any code.