note 105941 added to function.array-map
| From: | erik dot stetina at gmail dot com | Date: | Tue, 27 Sep 2011 10:03:24 +0000 |
| Subject: | note 105941 added to function.array-map | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183466@lists.php.net to get a copy of this message | ||
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
)
----
Server IP: 69.147.83.197
Probable Submitter: 92.52.35.25
----
Manual Page -- http://www.php.net/manual/en/function.array-map.php
Edit -- https://master.php.net/note/edit/105941
Del: integrated -- https://master.php.net/note/delete/105941/integrated
Del: useless -- https://master.php.net/note/delete/105941/useless
Del: bad code -- https://master.php.net/note/delete/105941/bad+code
Del: spam -- https://master.php.net/note/delete/105941/spam
Del: non-english -- https://master.php.net/note/delete/105941/non-english
Del: in docs -- https://master.php.net/note/delete/105941/in+docs
Del: other reasons-- https://master.php.net/note/delete/105941
Reject -- https://master.php.net/note/reject/105941
Search -- https://master.php.net/manage/user-notes.php