Category: PHP

You can’t, or shouldn’t, create thousands of different variables to store each record. You would use an array and store all of the records under one variable.

In the $drivers_i_hate array, we have 3 elements; the index values are 0, 1, and To access the first array element, you’ll take your variable, $drivers_i_hate, append a couple of brackets to it, [ ], and place the index value in between the brackets.

We can add an array element to the end of the array by using the array name, append the square brackets to the end of the name, insert the last index value + 1 inside the brackets, and finally assign the value to it.

If we wanted to remove the last element that we just added, element at index 26, and reinsert it as the last element in the array, we can, but we get some unexpected results.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners