View Single Post
  #34 (permalink)  
Old 08-17-2007, 01:14 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Info array_map() Function

The array_map() function sends each value of an array to a user-made function, and returns an array with new values, given by the user-made function.
Applies the callback to the elements of the given arrays.

Syntax
Quote:
array array_map ( callback callback, array arr1 [, array ...] )
Description

array_map() returns an array containing all the elements of arr1 after applying the callback function to each one. The number of parameters that the callback function accepts should match the number of arrays passed to the array_map()

Example

PHP Code:
<?php
function cube($n)
{
    return(
$n $n $n);
}

$a = array(12345);
$b array_map("cube"$a);
print_r($b);
?>
This makes $b have:
Code:
Array
(
    [0] => 1
    [1] => 8
    [2] => 27
    [3] => 64
    [4] => 125
)
__________________
With,
J. Jeyaseelan

Everything Possible
Reply With Quote