Example 1 — Remove the First Item
Take the first person off a waiting list.
<?php
$queue = ["Ann", "Ben", "Cara"];
$first = array_shift($queue);
echo "Removed: ", $first, PHP_EOL;
echo "Remaining: ", implode(", ", $queue), PHP_EOL; How It Works
- Create a queue with three names.
- array_shift() removes "Ann" from the front and returns it.
- $queue now contains only "Ben" and "Cara".
- implode() joins the remaining names with commas for printing.

