array_is_list(array $array): bool
The function returns true if the array is a list and false otherwise.
$array = [10, 20, 30];
$result = array_is_list($array);
echo $result ? 'True' : 'False';
True
$array = ['a' => 1, 'b' => 2];
$result = array_is_list($array);
echo $result ? 'True' : 'False';
False
$array = [0 => 'apple', 'x' => 'banana', 1 => 'orange'];
$result = array_is_list($array);
echo $result ? 'True' : 'False';
False
$array = [];
$result = array_is_list($array);
echo $result ? 'True' : 'False';
True
$array = [0 => 'apple', 2 => 'banana', 3 => 'orange'];
$result = array_is_list($array);
echo $result ? 'True' : 'False';
False
$array = [1=>'Green',2=>'Red',3=>'Blue']; // Not starting with 0
$result = array_is_list($array);
echo $result ? 'True' : 'False';
False
$array = [-1=>'Green',0=>'Red',1=>'Blue']; // Not starting from 0
$result = array_is_list($array);
echo $result ? 'True' : 'False';
False
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.