Example for array_walk_recursive
$aData = array();
$aData['ebene1'] = array_fill(0, 2, 'Wert1');
$aData['ebene1']['ebene2'] = array_fill(0, 2, 'Wert2');
var_dump($aData);
/**
* Ausgabe (vorher)
array(1) { ["ebene1"]=> array(3)
{[0]=> string(5) "Wert1"
[1]=> string(5) "Wert1"
["ebene2"]=> array(2)
{[0]=> string(5) "Wert2"
[1]=> string(5) "Wert2"}}
}
*/
function encodeToBase64(&$aItem, $mKey)
{
$aItem = base64_encode($aItem);
}
array_walk_recursive($aData, "encodeToBase64");
var_dump($aData);
/*
* Ausgabe (nachher):
array(1) { ["ebene1"]=> array(3)
{[0]=> string(8) "V2VydDE="
[1]=> string(8) "V2VydDE="
["ebene2"]=> array(2)
{[0]=> string(8) "V2VydDI="
[1]=> string(8) "V2VydDI="}}
}
*/
Url: http://sklueh.de/2012/09/alle-elemente-eines-mehrdimensionalen-array-durchlaufen-und-bearbeiten/
Language: PHP | User: sklueh | Created: Sep 24, 2013