International PHP Conference Munich 2025

Voting

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

The Note You're Voting On

jerk at yoosic dot de
18 years ago
if you want to modify every value of an multidimensional array use this function used here:

<?php

$array
= array (1=>1, 2=> 2, 3 => array(1=>11, 2=>12, 3=>13));
$text = "test";

function
modarr(&$array, $text) {
foreach (
$array as $key => $arr) {
if(
is_array($arr)) $res[$key] = modarr(&$arr,$text);
// modification function here
else $res[$key] = $arr.$text;
}
return
$res;
}

$erg = modarr($array, $text);

print_r($erg);

?>

result will be_

<?php
Array ( [1] => 1test [2] => 2test [3] => Array ( [1] => 11test [2] => 12test [3] => 13test ) )
?>

<< Back to user notes page

To Top