I was able to successfully apply the
array_walk function to an array in
this thread however to use the array after the function is applied more then once it would require using
array_walk each time so I am trying to figure out how to permanently apply
array_walk to an array or to assign it to a new array. I attempted to apply the
array_walk to a new variable...presuming it might create an array out of the variable...in a funny way though after using the
is_array function and testing the variable/array with print_r I'm not sure what to do at the moment in time...so a little direction would be greatly appreciated so I can reuse the array without having to reprocess it each time I wish to use it!
Here is what I have tried...
Code: Select all
<?php
$fruits = array("Lemony & Fresh","Orange Twist","Apple Juice");
$fruits_fixed = array_walk($fruits, 'name_base');
function name_base($key)
{
$name2 = str_replace(" ", "_", $key);
$name3 = str_replace("&", "and", $name2);
$name4 = strtolower($name3);
//echo $name4.'<br />';
return $name4;
}
print_r($fruits_fixed);
echo '<br />';
if (is_array($fruits_fixed)) {echo 'is array';}
else {echo 'not array';}
?>