troubleshooting Question

Can you tell me why I get this error please.?

Avatar of EagleJess
EagleJess asked on
PHP
12 Comments2 Solutions144 ViewsLast Modified:
17,16,21,2,5,13,11,10,7,14,8,0,18,20,15,1,4,3,6,9,12,19
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/test_qu2.php on line 3

My code is:
<?php
   function contain($boxValues, $number) {
     for ($k=0; $k<sizeof($boxValues); $k++) {
       if ($boxValues[$k] == $number)
            return true;
     }
       return false;
   }
 
   $num[0] = rand(1,21);
   echo $num [0];
   $boxValues[0] = $num[0];
   for ($i=1; $i<=22; $i++) {      
      $num[$i] = rand(0,21);      
      while (contain($boxValues, $num[$i])) {          
         $num[$i] = rand (0,21);      
      }      
    $boxValues[$i] = $num[$i];    //append into the array  
   
      echo "," .$num[$i];
      }  
     
            
?>
SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros