7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPよかった探し(array_map)

Last updated at Posted at 2013-06-28

PHPちょうべんりですね()

touch.php
<?php
$files = array(
    '/tmp/a.txt',
    '/tmp/b.txt',
    '/tmp/c.txt',
);

// 空ファイルつくる
array_map('touch', $files);
// ファイル消す
array_map('unlink', $files);
  • まじめに補足しておくと、この簡潔さはRubyやPythonでは出しにくいですね
  • といふか、この例に限ってはこころなしかLispっぽさありますね
    • 副作用目的であって、返値を捨ててるのがアレだけど
  • でもな… 函数名の文字列… 文字列…
    • callable の仕様作った人すごい… (虚ろな目をしながら)
7
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?