<?php
$string = 'hello';
echo preg_replace('/he(l)l(o)/', '$0, $1, $2', $string);