Thread: Randomize code
View Single Post
Old 05-05-2008, 08:52 AM   #6 (permalink)
sjaq
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

With numbers
PHP Code:
<?php 

    $str 
'XXXX-XXX-XXX-XX-XXXX';
    
    echo 
preg_replace_callback('/X/'create_function('$match''return rand(0, 1)? chr(rand(65, 90)) : chr(rand(48, 57));'), $str);

?>
@Orc: your code will generate the same string every time so it isn't that random
sjaq is offline  
Reply With Quote
The Following User Says Thank You to sjaq For This Useful Post:
Tanax (05-05-2008)