if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_POST["icase"] == "getPics"){ $images = glob('./pics/*.{jpeg,gif,png,jpg}', GLOB_BRACE); shuffle($images); echo json_encode(($images)); }else{ $start = 0; $limit = 30; /* if(isset($_GET['limit'])){ $start = $limit * $_GET['limit'] - $limit; $limit = $limit * $_GET['limit']; } */ $images = glob('./pics/*.{jpeg,gif,png,jpg}', GLOB_BRACE); shuffle($images); $key = 0; //print_r($images); foreach($images as $image){ if($key >= $start && $key <= $limit){ echo(''); } $key++; } }