Hello there, im working to some code but i get stuck hope someone can help me with this function id( $id ) { $1 = array( "1", "t", "r" ); if (preg_match("/1/i", $id)) { $id = str_replace('1', $1[rand(0,3)], $id); } return $id; } PHP: if i put like this echo id( '1221133' ); will show me " r22rr33 " how i can make to get random value for every 1 example to be " r22t133 "
You can use for () $newstr = ''; for ($i = 0; $i < strlen($str); $i++) {if ($str[$i] == '1') {$newstr.= rand(0,3);} else {$newstr .= $str[$i];} } echo $newstr; PHP:
One issue with your existing code is that rand might be calling a non-existent element. It should be rand(0,2) since there are only 3 items total in the $1 array. Can you tell me how you plan on reversing the encryption, since there's a possibility of 1 being replaced by 1? Thanks
The script can show how lol 1 will not be all time 1 can be t or r hard to find the real code ... anyway what i put there on the script its just example i just need the command to can get every 1 with difrent value 1 or t or r exampe 1211223 = r2t1223 or t2tr223 or etc ...
You can't have variables that are just a number, or starting with a number. $1 will not work. $asdf is better.