Example 1 — Drop the Keys
Turn an associative array into a simple list.
<?php
$person = ["name" => "Ann", "city" => "Paris"];
$list = array_values($person);
echo json_encode($list), PHP_EOL; How It Works
- The array has the string keys "name" and "city".
- array_values() collects just the values in order.
- New keys 0 and 1 are assigned.
- json_encode() prints the list as a JSON array.

