wesley Posted October 12, 2015 Share Posted October 12, 2015 Hello,I have make a random string with a array. The letters A, B and C are in a array.The letters must be see random in the browser, all three next to each other. But this doesn't work. Now the letters ABC are static in the browser and not random if you refresh the page.Can someone help me? How can I get the letters random?thanks in advcance.my code is: <?php$a=array("A","B","C");$random_keys=array_rand($a, 3);echo $a[$random_keys[0]];echo $a[$random_keys[1]];echo $a[$random_keys[2]]; Link to comment Share on other sites More sharing options...
justsomeguy Posted October 12, 2015 Share Posted October 12, 2015 The order of the keys is not random. If you want to shuffle the array you can use the shuffle function. Link to comment Share on other sites More sharing options...
davej Posted October 12, 2015 Share Posted October 12, 2015 The user comments here are mostly complaints about this function... http://php.net/manual/en/function.array-rand.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now