Jump to content

Am I asking the impossible


xn1

Recommended Posts

First question: is the third line of code here even nessesary

$_SESSION['asked']=array();
$catagories = array("easy", "medium", "hard");

$random = $catagories[mt_rand(0, count($catagories)-1)].mt_rand(1,5);

while(in_array($random, $_SESSION['asked'])) {
$random = $catagories[mt_rand(0, count($catagories)-1)].mt_rand(1,5);
        } $_SESSION['asked'][] = $random;

This then generates one of 15 options (currently), those being easy1, easy2, easy3, easy4, easy5, medium1, medium2, medium3, medium4, medium5, hard1, hard2, hard3, hard4, hard5.

 

My second question is, can I give this generator the ability to generate hard6, hard7, hard8, hard9 and hard10, while not generating anything higher than 5 with easy and medium?

Link to comment
https://forums.phpfreaks.com/topic/231572-am-i-asking-the-impossible/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.