Voting

: max(two, four)?
(Example: nine)

The Note You're Voting On

jab_creations_-at_-yahoo_-dot-_com
16 years ago
Unfortunately I spent a lot of time trying to permanently apply the effects of a function to an array using the array_walk function when instead array_map was what I wanted. Here is a very simple though effective example for those who may be getting overly frustrated with this function...

<?php
$fruits
= array("Lemony & Fresh","Orange Twist","Apple Juice");

print_r($fruits);
echo
'<br />';

function
name_base($key)
{
$name2 = str_replace(" ", "_", $key);
$name3 = str_replace("&", "and", $name2);
$name4 = strtolower($name3);
echo
$name4.'<br />';
return
$name4;
}
echo
'<br />';

$test = array_map('name_base', $fruits);
$fruits_fixed = $test;
echo
'<br />';
print_r($fruits_fixed);
?>

<< Back to user notes page

To Top