-------------------------------------------------------------------------------------------------------- array array_map( callable $callback , array $arr1 [, array $... ] ) array_map()返回一个数组,该数组包含了 arr1 中的所有单元经过 callba
--------------------------------------------------------------------------------------------------------
array array_map ( callable $callback
, array $arr1
[, array $...
] )
array_map() 返回一个数组,该数组包含了 arr1
中的所有单元经过 callback
作用过之后的单元。
callback
接受的参数数目应该和传递给 array_map() 函数的数组数目一致。
<span>function</span> fun(<span>$n</span><span>) { </span><span>return</span> <span>$n</span> * <span>$n</span> * <span>$n</span><span>; } </span><span>$a</span> = <span>array</span>(1, 2, 3, 4, 5<span>); </span><span>$b</span> = <span>array_map</span>('fun', <span>$a</span><span>); /* 每个数组单元作三次方运算,返回数组 */ </span><span>print_r</span>(<span>$b</span>);<br>/*<br>Array
( [0] => 1 [1] => 8 [2] => 27 [3] => 64 [4] => 125 )<br>*/
<span>array_map</span>('unlink', <span>glob</span>('*.txt'));<em>/* glob返回"文件名.txt"组成的数组,然后对每个文件进行删除操作*/<br><br></em>
array_map('unlink', glob('*.*'));<br><br>array_map('unlink', glob('*'));
如果不使用array_map(),对数组每个单元进行操作就只能遍历然后适当组装。
Link: http://www.cnblogs.com/farwish/p/3836837.html
@黑眼诗人

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
