PHP array_walk_recursive() 函數(shù)
PHP array_walk_recursive() 函數(shù)
實(shí)例
對(duì)數(shù)組中的每個(gè)元素應(yīng)用用戶(hù)自定義函數(shù):
<?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");
?>
運(yùn)行實(shí)例 ?
定義和用法
array_walk_recursive() 函數(shù)對(duì)數(shù)組中的每個(gè)元素應(yīng)用用戶(hù)自定義函數(shù)。在函數(shù)中,數(shù)組的鍵名和鍵值是參數(shù)。該函數(shù)與 array_walk() 函數(shù)的不同在于可以操作更深的數(shù)組(一個(gè)數(shù)組中包含另一個(gè)數(shù)組)。
語(yǔ)法
array_walk_recursive(array,myfunction,parameter...)
參數(shù) | 描述 |
---|---|
array | 必需。規(guī)定數(shù)組。 |
myfunction | 必需。用戶(hù)自定義函數(shù)的名稱(chēng)。 |
parameter,... | 可選。規(guī)定用戶(hù)自定義函數(shù)的參數(shù),您可以為函數(shù)設(shè)置一個(gè)或多個(gè)參數(shù)。 |
技術(shù)細(xì)節(jié)
返回值: | 如果成功則返回 TRUE,否則返回 FALSE。 |
---|---|
PHP 版本: | 5+ |

相關(guān)文章
- PHP 簡(jiǎn)介
- PHP 安裝
- PHP 語(yǔ)法
- PHP 變量
- PHP echo 和 print 語(yǔ)句
- PHP EOF(heredoc) 使用說(shuō)明
- PHP 類(lèi)型比較
- PHP 運(yùn)算符
- PHP If Else 語(yǔ)句
- PHP Switch 語(yǔ)句
- PHP 數(shù)組
- PHP 超級(jí)全局變量
- PHP While 循環(huán)
- PHP For 循環(huán)
- PHP 魔術(shù)常量
- PHP date() 函數(shù)
- PHP 包含文件 include 和 require 語(yǔ)句
- PHP 發(fā)送電子郵件
- PHP 錯(cuò)誤處理
- PHP 過(guò)濾器