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;
}
?>

Laravel Interview questions and answers

1. What is Laravel Laravel is free open source “PHP framework” based on MVC Design Pattern . It is created by Taylor Otwell. Laravel pro...