Kmspico Download | Official KMS Activator Website [New Version 2024] Uw betrouwbare online apotheek Drogisterij Unique in Nederland Vavada вход позволяет мгновенно попасть в мир азартных игр и бонусов! Получи доступ и начни выигрывать прямо сейчас.

array_walk_recursive() Function in PHP 8.2, PHP 8.3 & PHP 8.4 With Example

array_walk_recursive() Function in PHP 8.2, PHP 8.3 & PHP 8.4

The `array_walk_recursive()` function in PHP applies a user-defined function to every element of a multidimensional array. It works recursively, meaning it will process nested arrays as well.

Syntax:-

array_walk_recursive(array &$array, callable $callback, mixed $userdata = null): bool

`$array`: The input array (passed by reference).
`$callback`: A user-defined function to apply to each element.
`$userdata` (optional): Additional data to pass to the callback function.

Example:-

<?php
function modifyValues(&$value, $key, $prefix) {
$value = $prefix . $value;
}
$arr = [
"name" => "John",
"details" => [
"age" => 30,
"city" => "New York"
]
];

array_walk_recursive($arr, "modifyValues", "PHP-");
print_r($arr);
?>

Output:

Array
(
[name] => PHP-John
[details] => Array
(
[age] => PHP-30
[city] => PHP-New York
)
)