Zend - The PHP Company




Arrays

Add Code


array filter  

Type: application
Added by: sultanzahir
Entered: 16/11/2001
Last modified: 08/12/2008
Rating: - (fewer than 3 votes)
Views: 4935
with the function array filter one gets the value of any array as input and with the help of a callback for more functional editing and gets back a modified array.


<?PHP
function un_zahl($wert) {   
return (
$wert == 1);}
function 
a_zahl($wert) {
   return (
$wert == 0); 
}
$array1 = array ("a"=>1,"b"=>2,"c"=>3,"d"=>5);
$array2 = array (123456);
$werte1 array_filter($array1"un_zahl");
echo 
"non-straight values:<br>";
while(list(
$key$val) = each($werte1)){
  echo 
$val "<br>";
}
echo 
"straight values: <br>";
$werte2 array_filter($array2"a_zahl");
while(list(
$key$val) = each($werte2)){
  echo 
$val "<br>";
}
?>


Usage Example




Rate This Script





Search



This Category All Categories