Saturday, June 6, 2009

Lower Case an Array

Lower Case an Array

Here is an example of how to force all values in array tolower case. This could, of course, be used in the same way to make the array UPPERCASE or do anything else you wish to the array values. Note the that the string is passed to the array by reference. This is so the actual array values are manipulated.

<?php

/*** an array of mixed case words ***/
$array = array('MAC', 'Apple', 'osX');

/**
*
* @Lower case an array
*
* @param ref string $string
*
* @return string
*
*/
function lower(&$string){
$string = strtolower($string);
}

/*** apply the lower function to the array ***/
array_walk($array,'lower');

foreach($array as $value){
echo $value;
}
?>

manually load scan dir / load directory in command line php

For checking of the .ini loaded via command line is php --ini If scan directory is mentioning the right path of additional loading d...