preg_replace_callback works by sending every matched capturing group to the defined callback and replaces it with the return value of the callback.
This allows us to replace strings based on any kind of logic.
$subject = "He said 123abc, I said 456efg, then she said 789hij";
$regex = &q...