In PHP, how do I create arrays for beginners?

Creating arrays in PHP is a simple and fundamental concept that every beginner should learn. Arrays allow you to store multiple values in a single variable, making your code cleaner and more efficient. Here you will find some examples of how to create arrays in PHP.

Keywords: PHP arrays, create arrays in PHP, beginner PHP tutorial, PHP programming
Description: This tutorial provides a beginner-friendly introduction to creating arrays in PHP, including examples of indexed and associative arrays.
<?php // Creating an indexed array $fruits = array("Apple", "Banana", "Cherry"); // Accessing array elements echo $fruits[0]; // Outputs: Apple // Creating an associative array $person = array( "name" => "John", "age" => 30, "city" => "New York" ); // Accessing associative array elements echo $person['name']; // Outputs: John ?>

Keywords: PHP arrays create arrays in PHP beginner PHP tutorial PHP programming