Forum Moderators: coopster
return str_replace('apples-<$RANDOM NUMERIC INPUT(1)HERE$>' , 'oranges-<$SAME NUMBER AS RANDOM INPUT(1)$>' , $s )
any light on this would be appreciated!
thnx in advance
$string = 'apples-1777732'; # test case
#
$pattern = '/apples-(\d+)/';
$replacement = 'oranges-\\1'; # \\1 here is the random number
$new_string = [url=http://www.php.net/preg-replace]preg_replace[/url]($pattern, $replacement, $string);
echo $new_string;