<?php // Create an array and push on the names $players = array(); array_push($players,"Holly"); array_push($players,"Tina"); array_push($players,"John"); array_push($players,"Eric"); array_push($players,"David"); array_push($players,"Behemoth"); // of your closest family and friends // Sort the list sort($players); $maxCount = count($players);?><br><?php // Randomly select a winner! $winner = $players[rand(0,$maxCount-1)]; echo strtoupper($winner);
randint is a built in function which generates a random integer, between zero length of array minus one to randomly select a player from your array
randint is built in function ok its generate a random no between zero to lenth of array ok but minus one not understand
plz help once.
we humans start counting at 1, so does count()
but arrays are zero indexes based, this is why we subtract one, to compensate for this difference
Hey stetim94 Thanks you make my day !
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.