PHP Classes
elePHPant
Icontem

File: arrayMinValue.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Shibly  >  PHP Array Sort Algorithms class  >  arrayMinValue.php  >  Download  
File: arrayMinValue.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Array Sort Algorithms class
Sort arrays values using multiple algorithms
Author: By
Last change:
Date: 1 year ago
Size: 482 bytes
 

Contents

Class file image Download
<?php
function minVal(array $array) {
       
$length=count($array);
        for (
$i=0;$i<$length;$i++) {
           
$min=$i;
            for (
$j=$i+1;$j<$length;$j++) {
                if (
$array[$j]>$array[$min]) {
                   
$min=$j;
                }
            }
           
$tmp=$array[$min];
           
$array[$min]=$array[$i];
           
$array[$i]=$tmp;
        }
        return
$array[0];
    }


   
$data = minVal(array(0,8,7,6,5,4,3,2,1,9));
    echo
$data;
?>