Chapter 8: Arrays
Chapter 8 of 15
Chapter 8: Arrays
8.1 Creating Arrays
// Indexed array
$fruits = ["apple", "banana", "orange"];
// Associative array
$person = [
"name" => "John",
"age" => 30,
"city" => "New York"
];
8.2 Accessing Array Elements
echo $fruits[0]; // apple
echo $person["name"]; // John
8.3 Array Functions
count($array); // Get array length
array_push($array, $item); // Add to end
array_pop($array); // Remove from end
in_array($value, $array); // Check if value exists