bb90 Posted March 14, 2011 Share Posted March 14, 2011 Hi, Does anyone know how to create a php file which will ask the user to enter three random characters from their pre-selected word. It would be like with online banking where you have to enter for example letters 2, 4 and 5 from your memorable data. Any help would be greatley appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/230591-memorable-word-how-to-ask-for-three-random-letters/ Share on other sites More sharing options...
silkfire Posted March 14, 2011 Share Posted March 14, 2011 This is an interface question doesn't have much to do with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/230591-memorable-word-how-to-ask-for-three-random-letters/#findComment-1187329 Share on other sites More sharing options...
HuggieBear Posted March 14, 2011 Share Posted March 14, 2011 This should get you started // Set secret word $word = 'mysecretword'; // How many letters must they provide $required_letters = 3; // Populate array with letters keyed on their position $letters = array(); while (count($letters) < $required_letters){ $k = rand(1, strlen($word)); $letters[$k] = substr($word, $k-1, 1); } // Sort if you want them to enter the letters in order ksort($letters); // Print array echo '<pre>'; print_r($letters); echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/230591-memorable-word-how-to-ask-for-three-random-letters/#findComment-1187338 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.