Using the key not value in a callback function part of array_walk in php

one text

Solution:

Just like its mentioned in the PHP documentation here https://www.php.net/manual/en/function.array-walk.php

Typically, callback takes on two parameters. The array parameter's value being the first, and the key/index second.

So array_walk($first_names, function($item) {

should be array_walk($first_names, function($value, $key) {

Source