Just for curiosity (I know it can be a single line foreach statement), is there some PHP array function (or a combination of many) that given an array like:
The easiest way is to use a LINQ port like YaLinqo library*. It allows performing SQL-like queries on arrays and objects. Its toDictionary function accepts two callbacks: one returning key of the result array, and one returning value. For example:
$userNamesByIds = from($users)->toDictionary(
    function ($u) { return $u->id; },
    function ($u) { return $u->name; }
);
Or you can use a shorter syntax using strings, which is equivalent to the above version:
$userNamesByIds = from($users)->toDictionary('$v->id', '$v->name');
If the second argument is omitted, objects themselves will be used as values in the result array.
* developed by me