note 105941 deleted from function.array-map by danbrown

From: Date: Tue, 27 Sep 2011 14:19:54 +0000
Subject: note 105941 deleted from function.array-map by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183483@lists.php.net to get a copy of this message
Note Submitter: erik dot stetina at gmail dot com ---- function to prefix given string to each element of an array: <?php function array_prefix_values($prefix, $array) { $callback = create_function('$str','return "'.$prefix.'".$str;'); return array_map($callback,$array); } ?> usage: <?php $dir = "./css/"; $files = scandir($dir); $files = array_prefix_values($dir,$files); print_r($files); ?> output: ( [0] => ./css/. [1] => ./css/.. [2] => ./css/default.css [4] => ./css/helper.css [6] => ./css/page_layout.css )

« previous php.notes (#183483) next »