How do I make all the values in my array lowercase? Is there an array function that can this?
thanks in advance,
Keith
How do I make all the values in my array lowercase? Is there an array function that can this?
thanks in advance,
Keith
hi
in java.lang package,
one method is available called toLowerCase(Locale)
u can convert to lowercase array of contents.
regards,
siva
array_map( ‘strtolower’ , $array );
Thanks for the reply. But it just outputs ArrayArrayArray
// Make all the elements lowercase
for($i=0; $i<count($articlesLower); $i++)
{
echo array_map( 'strtolower' , $articlesLower );
}
Got it:
echo strtolower ($articlesLower[$i]) . "<br />";
No, I posted the 2 functions that you need to find out about, I expected you to go and look up how to make it work in the manual.
$a = array(
'UPPER',
'UPPER',
'UPPER',
);
// remap here
$b= array_map('strtolower' , $a );
var_dump( $b );
array(3) {
[0]=>
string(5) "upper"
[1]=>
string(5) "upper"
[2]=>
string(5) "upper"
}
hi,
sorry
i thougt that for java coding friend.soory
php i dont know…
siva
If you are still having problems, and simple way to perform this is to loop through the array using foreach() and use strtolower on each value inside of the array.
To put the above into code:
<?php
$arr = array("A", "B", "C");
foreach($arr as $key => &$value){
$value = strtolower($value);
}
?>
However array_map() is what you should use (just don’t echo it).