You can use the function rand()
:
$str = str_replace(' ', rand(0, 10000), $str);
Or did you mean a random value from your list? In this case:
$list = array("value1", "value2");
$str = str_replace(' ', array_rand($list, 1), $str);
1
solved replace spaces with randam values [closed]