How to get unique random image and not the same shape??

Discussion in 'PHP' started by 123GoToAndPlay, Mar 10, 2010.

  1. #1
    hi,

    I am trying to get 3 random images out of a pool of 15 images(let say shapes square, circle and
    , but the images must be
    - unique so no repeat
    - some shapes just once
    - some images more "random", so a higher change to appear

    for the non repeat i use
    
    	function non_repeat($min, $max, $count, $sort = false)
    	{
    		/**
    		*	method outputs an unique array within a range 
    		*	
    		*	$min	begin range
    		*	$max 	end range
    		*	$count	 output
    		**/
    		if ($max - $min < $count) {
    			return false;
    		}
    		$arr = range($min, $max);
    		$arr_rnd = array_rand($arr, $count);
    		foreach ($arr_rnd as $each) {
    			$nonrepeatarray[] = $arr[$each];
    		}
    		if (!$sort) {    
    			shuffle($nonrepeatarray);
    		}
    		return $nonrepeatarray;
    	}
    
    Code (markup):
    What should i do next??
     
    123GoToAndPlay, Mar 10, 2010 IP
  2. odrey

    odrey Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hi..
    try to registering your image to the session, so it will no repeat
     
    odrey, Mar 29, 2010 IP