Change specific keys of multidimensional array in PHP -
i have 2 dimensional array called $array
. after question here, know how change whole child array 2 dimensional array this:
code
$keys = array(0, 1); foreach ($keys $key) { foreach ($array[$key] $key2 => $value) { $array[$key][$key2] = str_replace($stamm, $stamm2, $value); } }
how possible change $array[0][3],$array[0][4]
, $array[1]
?
$array use $stamm
+ ending of verb time example "ons". have change cases root of verb ($stamm
).
code above works change whole array[0]
, array[1]
. .
why dont
$array[0][3] = //your value; $array[0][4] = //your value;
and if want change value of $array[1]
:
foreach ($array[1] $key => $value) { $array[1][$key] = //your value; }
edit foreach :
foreach ($keys $key) { foreach ($array[$key] $key2 => $value) { if(($key==0 && ($key2 == 3 || $key2 == 4)) || ($key == 1) ) $array[$key][$key2] = //your value; } }
Comments
Post a Comment