PHP - Help me debug this script please

Hey,

Can you guys help me debug this code? What I want to do is to get information about 4 random unvisited page, in my site. Code generally workes just fine. But after a while it start to give errors. I guess it is because of the more pages being viewed. Problem is probably with the line

$random_keys = (count($no_visits)>4 ? array_rand($no_visits,4) : $no_visits);

Because the error I get is undefined index in the line

$random_not_visited] = $no_visits$random_key]

This is the whole part related to problem :


<?php
$ids = $this->zippo_model->id_array(); //array of all id's
		$viewed = $this->session->userdata('visited'); //visited id's
		if(is_array($viewed)) $viewed] = $id; //add this page to viewed
		$no_visits = array_diff($ids,$viewed); //substract  viewed from id's
		$random_keys = (count($no_visits)>4 ? array_rand($no_visits,4) : $no_visits); // if $no_visits larger than 4 item, take 4 random key, otherwise take whole array
		foreach($random_keys as $random_key){ //foreach random key
			$random_not_visited] = $no_visits$random_key]; //add this to array
		}
		if(is_array($random_not_visited)){
			foreach($random_not_visited as $not_visited){
				$zippo = $this->zippo_model->get_from_id($not_visited); //get information about not visited id
				$unvisiteds] = array('id' => $zippo->id, 'isim' => $zippo->isim); //store new information on array
			}
		}
?>

I have solved the problem, if anyone wonders the solution, here it is:


$ids = $this->zippo_model->id_array();
		$viewed = $this->session->userdata('visited');
		if(is_array($viewed)) $viewed] = $id;
		$no_visits = (@is_array($viewed) ? array_diff($ids,$viewed) : $ids);
		$random_keys = (count($no_visits) > 4 ? array_rand($no_visits,4) : array_keys($no_visits));		
		foreach($random_keys as $random_key){
			$random_not_visited] = $no_visits$random_key];
		}
		if(@is_array($random_not_visited)){
			foreach($random_not_visited as $not_visited){
				$zippo = $this->zippo_model->get_from_id($not_visited);
				$unvisiteds] = array('id' => $zippo->id, 'isim' => $zippo->isim);
			}
		}