use preg_replace_callback() instead of preg_replace() 

Starting with php 5.5 preg_replace() with /e modifier is deprecated.

This patch proposal is compatible with older version.
Should be also faster (single pass).