note 79849 deleted from language.functions by nlopess
| From: | nlopess@php.net | Date: | Sat, 15 Dec 2007 10:23:06 +0000 |
| Subject: | note 79849 deleted from language.functions by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133539@lists.php.net to get a copy of this message | ||
Note Submitter: lazar at inverudio dot com
----
Running many functions on a variable with foreach array iterator.
<?php
function f1($var){
$var .= '1'; // dosomethingwith($var)
echo $var;
}
function f2($var){
$var .= '2'; // dosomethingelsewith($var)
echo $var;
}
function f3($var){
$var .= '3'; // dosomethingsame($var)
echo $var;
}
$taskA_functions = array('f1','f2');
$taska = ' taskA';
$taskB_functions = array('f1','f3');
$taskb = ' taskB';
foreach($taskA_functions as $f){
$f($taska);
}
foreach($taskB_functions as $f){
$f($taskb);
}
?>
Above returns:
taskA1 taskA2 taskB1 taskB3
Lazar
--
http://www.inverudio.com