PHP Classes

File: examples/SortedFind.php

Recommend this page to a friend!
  Classes of Christian Vigh   PHP Array Helpers   examples/SortedFind.php   Download  
File: examples/SortedFind.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Array Helpers
Perform several array manipulation operations
Author: By
Last change: Update of examples/SortedFind.php
Date: 1 year ago
Size: 824 bytes
 

Contents

Class file image Download
<?php
   
/***********************************************************************************************************

        The following example demonstrates the use of the ArrayHelpers::SortedFind function.

     ***********************************************************************************************************/
   
require ( '../ArrayHelpers.phpclass' ) ;

    if (
php_sapi_name ( ) != 'cli' )
        echo (
"<pre>" ) ;

   
$array = range ( 1000000, 2000000 ) ;

   
// Find item 1500000
   
$index = ArrayHelpers::SortedFind ( $array, 1500000 ) ;
    echo
"Find item 1 500 000 in an array containing sorted values from 1 000 000 to 2 000 000 :\n" ;
   
$index = ArrayHelpers::SortedFind ( $array, 1500000 ) ;
    echo
"\tFound item at index : $index\n" ;
    echo
"\tValue at index $index : " . $array [ $index ] . "\n" ;