Some days before came across an interview, where in I have to face the basics for Team Leader.
so my friends beware hope you will find this functions useful. Although there are short ways but still some people want to take the same long ways.
Here are the functions :
//Max element of an array
function max_array($array){
$max = $array[0];
for($i=0;$i < count($array);$i++){
if($array[$i] > $max){
$max = $array[$i];
}
}
return $max;
}
//min of an array
function min_array($array){
$min = $array[0];
for($i=0;$i < count($array);$i++){
if($array[$i] < $min){
$min = $array[$i];
}
}
return $min;
}
//sort an array using bubble sort
function array_sort($array){
for($i=0; $i < count($array); $i++){
for($j=0; $j < count($array)-1; $j++){
if($array[$j] > $array[$j+1]){
$temp = $array[$j+1];
$array[$j+1] = $array[$j];
$array[$j] = $temp;
}
}
}
return $array;
}
//check if a string is a palendrom
function check_palendrom($str){
for($i=0;$i < strlen($str)/2;$i++){
if($str[$i] != $str[count($str) - $i -1]){
return "Not palendrom";
}
}
return "Palendrom";
}
- Kiran's blog
- 246 reads













So carry on with a fresher team lead ha ha ha ---
Company name can't be disclosed, but it's the truth
Buddy what is the company name
Post new comment