Appending to an Array in PHP


Directly append an item to an array without specifying a key.

Source Code

$array = ["apple", "banana"];
$array[] = "cherry";
print_r($array); // Adds "cherry" to the array
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments