function get_question($type, $questions) { global $main, $_SESSION; $random_question = rand(1, $questions['count']); while ($_SESSION['questions'][$type][$random_question]) { $random_question = rand(1, $questions['count']); } return $random_question; }