Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

array map function syntax tag tutorial 2013  # Php array map () function

<?php ?>

### Php Result

(PHP 4 >= 4.0.6, PHP 5)

array_map --  Applies the callback to the elements of the given arrays

## Syntax

array array_map ( callback callback, array arr1 [, array ...] )

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 1. array_map() example

 ``` ```

This makes \$b have:

 ```Array (  => 1  => 8  => 27  => 64  => 125 )```

Example 2. array_map() - using more arrays

 ``` \$m));}\$a = array(1, 2, 3, 4, 5);\$b = array("uno", "dos", "tres", "cuatro", "cinco");\$c = array_map("show_Spanish", \$a, \$b);print_r(\$c);\$d = array_map("map_Spanish", \$a , \$b);print_r(\$d);?> ```

The above example will output:

 ```// printout of \$c Array (  => The number 1 is called uno in Spanish  => The number 2 is called dos in Spanish  => The number 3 is called tres in Spanish  => The number 4 is called cuatro in Spanish  => The number 5 is called cinco in Spanish ) // printout of \$d Array (  => Array (  => uno )  => Array (  => dos )  => Array (  => tres )  => Array (  => cuatro )  => Array (  => cinco ) )```

Usually when using two or more arrays, they should be of equal length because the callback function is applied in parallel to the corresponding elements. If the arrays are of unequal length, the shortest one will be extended with empty elements.

An interesting use of this function is to construct an array of arrays, which can be easily performed by using NULL as the name of the callback function

Example 3. Creating an array of arrays

 ``` ```

The above example will output:

 ```Array (  => Array (  => 1  => one  => uno )  => Array (  => 2  => two  => dos )  => Array (  => 3  => three  => tres )  => Array (  => 4  => four  => cuatro )  => Array (  => 5  => five  => cinco ) )```

## Php array map Function syntax tag

array map php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online

### Php array map syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.

Function index

Variables

Expressions

Operators

Control-Structures

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites

Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online