I have a string of delimiter-separated values, and need to perform some_func on each of the values in the string. What is the most compact/elegant way to accomplish this? Here is the code I would currently use:
$delim = ',';
$source_array = explode($delim, $source_string);
$destination_array = array();
foreach ($source_array as $val) {
$destination_array[] = some_function($val);
}
$destination_string = implode($delim, $destination_array);
Ordering is not important, but would be nice to preserve.
Thanks!
You’re looking for
array_map: