PHP 8.5.0 Alpha 2 available for testing

Voting

: max(seven, five)?
(Example: nine)

The Note You're Voting On

emre
4 years ago
You can change the key or value with array_walk if you use the temporal returned array in global inside the function. For example:

$array = ['a'=>10, 'b'=>20];
$sequence = array ();

$newArray = array_values(array_walk($array, 'fn'));

function fn(&$val,$key){

global $sequence;

$sequence [] = $val;

}

No need to concern about the place of the internal pointer for the baby array. You have now rewinded, 0 based new array, string key one instead.

<< Back to user notes page

To Top