⊗ppPmArKT 57 of 447 menu

A Trick With Keys in PHP

It is not very convenient to assign keys to all elements just so that the numbering starts not from zero, but from one. Fortunately, in reality, it is enough to assign the key 1 to the first element, and then PHP will automatically assign the keys in order.

Let's try:

<?php $arr = [1 => 'a', 'b', 'c', 'd']; echo $arr[1]; // outputs 'a' echo $arr[2]; // outputs 'b' echo $arr[3]; // outputs 'c' ?>

Create an array with the names of the months. Let January have the key 1 in it.

byenru