<?php $string_source = 'blabla[Sun][Sun]blabla[Moon][Moon][Moon]blabla[Sun][Sun][Sun][Sun]blabla[Venus]'; $string_source = preg_replace_callback('/(\[[^\[\]]+\])+/', function($matches) { return $matches[1].'['.(strlen($matches[0])/strlen($matches[1])).']'; }, $string_source); var_dump($string_source);
You have javascript disabled. You will not be able to edit any code.