Just use preg_replace_callback()
:
$string_source = preg_replace_callback('/(\[[^\[\]]+\])+/', function($matches)
{
return $matches[1].'['.(strlen($matches[0])/strlen($matches[1])).']';
}, $string_source);
note, I do not rely on planets array because regex replace don't need to do it.
Fiddle is available here