Return smallest element greater than or equal to the current element .
function bsearch ( $ low , $ high , $ n , $ arr ) { $ mid = ( $ low + $ high ) / 2 ; if ( $ low <= $ high ) { if ( $ arr [ $ mid ] < $ n ) return bsearch ( $ mid + 1 , $ high , $ n , $ arr ) ; return bsearch ( $ low , $ mid - 1 , $ n , $ arr ) ; } return $ low ; }