A iterative binary search function . It returns location of x in given array arr [ l . . r ] if present , otherwise - 1
< ? php function binarySearch ( $ arr , $ l , $ r , $ x ) { while ( $ l <= $ r ) { $ m = $ l + ( $ r - $ l ) / 2 ;