Example 1 — Add to the Front
Put a new value at the start of a list.
<?php
$letters = ["b", "c"];
$count = array_unshift($letters, "a");
echo "Count: ", $count, PHP_EOL;
echo implode(", ", $letters), PHP_EOL; How It Works
- The list starts with "b" and "c".
- array_unshift() inserts "a" at the front.
- It returns the new size of the array, which is 3.
- The list now reads a, b, c.

