fonction array_walk_recursive PHP ()
PHP complet Tableau de référence
Exemples
Chaque élément de la fonction définie par l'utilisateur demande de tableau:
<?php
function myfunction($value,$key)
{
echo "The key $key has the value $value<br>";
}
$a1=array("a"=>"red","b"=>"green");
$a2=array($a1,"1"=>"blue","2"=>"yellow");
array_walk_recursive($a2,"myfunction");
?>
function myfunction($value,$key)
{
echo "The key $key has the value $value<br>";
}
$a1=array("a"=>"red","b"=>"green");
$a2=array($a1,"1"=>"blue","2"=>"yellow");
array_walk_recursive($a2,"myfunction");
?>
Exécution instance »
Définition et utilisation
array_walk_recursive function () pour chaque élément dans le tableau appliquent les fonctions définies par l'utilisateur. Dans la fonction, le tableau de noms et les valeurs clés sont des paramètres. Cette fonction array_walk () des fonctions différentes qui peuvent fonctionner ensemble plus profond (un tableau contenant d' autres tableaux).
grammaire
array_walk_recursive( array,myfunction,parameter... )
参数 | 描述 |
---|---|
array | 必需。规定数组。 |
myfunction | 必需。用户自定义函数的名称。 |
parameter,... | 可选。规定用户自定义函数的参数,您可以为函数设置一个或多个参数。 |
détails techniques
Retours: | En cas de succès, il retourne TRUE, sinon retourne FALSE. |
---|---|
PHP version: | 5+ |
PHP complet Tableau de référence