Maybe something like this:
Code:
<?php
$display = 'hello word - hello word - hello word';
global $find, $replace;
$find = array('/h/', '/o/');
$replace = array('1','2','3','4');
$output = preg_replace_callback($find, create_function(
'$matches',
'global $replace; return $matches[0] . $replace[array_rand($replace)];'
),
$display
);
echo $output;
There was an error in the previous code I posted that I didn't notice because the replace array is all numbers, but array_rand returns a key so you have to use the result in $replace[].
Also, the $find array is search patterns, which is why they start and end with '/'. If you're searching for strings with characters that are 'special' in patterns, then you might have to escape them with '\'.