text: Find a Fixed Point ( Value equal to index ) in a given array | PHP program to check fixed po in an array using binary search ; low + ( high - low ) / 2 ; ; Return - 1 if there is no Fixed Po ; Driver Code
code: < ? php function binarySearch ( $ arr , $ low , $ high ) { if ( $ high >= $ low ) { $ mid = ( int ) ( ( $ low + $ high ) / 2 ) ; if ( $ mid == $ arr [ $ mid ] ) return $ mid ; if ( $ mid > $ arr [ $ mid ] ) return binarySearch ( $ arr , ( $ mid + 1 ) , $ high ) ; else return binarySearch ( $ arr , $ low , ( $ mid - 1 ) ) ; } return -1 ; } $ arr = array ( -10 , -1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 ) ; $ n = count ( $ arr ) ; echo " Fixed ▁ Point ▁ is : ▁ " . binarySearch ( $ arr , 0 , $ n - 1 ) ; ? >