merhaba arkadaşlar yaşadığım sorun şu android uygulamasına json çıktı ile veri okutuyoruz fakat yeniler kısmındaki resim sayısı 9000 geçiyor bu yüzden çıktı sorunu yaşıyorum sorun çıkartan kısım ise echo '] , "recent" : { "images" : '; bölümü soracağım şu ben her seferinde recent bölümü için 1000 çıktı alabilirim miyim random olarak ?

<?php
set_time_limit(1000);
$dir = ".";
$return_array = array();
$r_array = array();
$boo = TRUE;

if (is_dir($dir)) {
	echo '{"category": [ ';
	if ($dh = opendir($dir)) {
		while (($file = readdir($dh)) != false) {
			if ($file == "." or $file == "..") {
			} else {
				if (is_dir($file)) {

					if ($boo) {
						echo '{ "name": ';
						$boo = FALSE;
					} else {
						echo ',{ "name": ';
					}
					$dir1 = './' . $file . '/';
					if ($dh1 = opendir($dir1)) {

						while (($file1 = readdir($dh1)) != false) {
							if ($file1 == "." or $file1 == "..") {
							} else {
								if (is_file($file)) {
								} else {
									$file_parts = pathinfo($file1);
									if ($file_parts['extension'] == "jpg" || $file_parts['extension'] == "png") {
										$r_array[] = $file1;
									}
								}
							}
						}
					}
					echo '"' . $file . '", "images": ';
					echo json_encode($r_array);
					echo '}';
					$r_array = null;
				}
			}
		}
	}
	echo '] , "recent" : { "images" : ';
}

$files = array();
$images_array = array();
 
if (is_dir($dir)) {
	if ($dh = opendir($dir)) {
		while (($file = readdir($dh)) != false) {
			if ($file == "." or $file == "..") {
			} else {
				if (is_dir($file)) {
					foreach (new DirectoryIterator($file) as $fileInfo) {
						$file_parts = pathinfo($fileInfo);
						if ($file_parts['extension'] == "jpg" || $file_parts['extension'] == "png") {
							//$x = $fileInfo -> getCTime();
							while(true) {
								if(in_array($x, $files)) {
									$x++;
									continue;
								} else {
									$files[$file . '/' . $fileInfo -> getFileName()] = $x;
									break;
								}
							}
						}
					}
				}
			}
		}
		arsort($files);
		foreach ($files as &$value) {
			$key = array_search($value, $files);
			$images_array[] = $key;
		}
	}
}
echo json_encode($images_array) . " } }";
?>