I have a function to replace each character by array:
function z3($str){ $text=$str; $sr = array( 'a' => array('A'), 'b' => array('B'), ' ' => array(' ') ); for ($i = 0, $len = strlen($text); $i < $len; $i++) { $news .= $sr[$text[$i]][@array_rand($sr[$text[$i]])]; } $nn=$news; return $nn; } echo z3("aaa"); And I need to develop it to if the character (a) was in the last word and after it is a space, I want to add ('s) to it. Let me explain:
$str = "aaa aaa aaa"; echo z3($str); I'd need the output to be AAA's AAA's AAA.
's. am i right?"ABB's ABA's ABc's ABA"I suspect. Or, if the "'s" is only added after an "a", then"ABB ABA's ABc ABA". Yes, highly unclear.