PHP arrays store multiple values in one variable and support both integer and string keys. Start with a simple indexed or associative array, then use the linked functions below to inspect, transform, sort, search and combine array data.
$fruits = ['Apple', 'Orange', 'Mango'];
echo $fruits[0]; // Apple
Use square-bracket syntax for new arrays; the older array() syntax remains valid when you encounter it in existing PHP code.
PHP arrays are powerful tools for storing multiple values within a single variable. This capability allows developers to organize data efficiently, accessing elements through indexes, which can be either numeric or string-based keys. An array is essentially a collection of variables, each referred to as an element. These elements can be directly retrieved using their specific indexes, simplifying data manipulation and retrieval in PHP programming.
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery,
and web development at plus2net. The tutorials focus on clear explanations, working
examples, and code that readers can test and adapt while learning.