PHP 8.4.24 Released!

Voting

: seven minus seven?
(Example: nine)

The Note You're Voting On

robin leffmann
11 years ago
A simple solution for walking a nested array to obtain the last set value of a specified key:

<?php

$key = 'blah';
$val = null;
array_walk_recursive( $your_array,
                      function($v, $k, $u) { if($k === $u[0]) $u[1] = $v; },
                      [$key ,&$val] );

echo "$key = $val";

?>

<< Back to user notes page

To Top