text: Find a Fixed Point ( Value equal to index ) in a given array | PHP program to check fixed point in an array using linear search ; If no fixed point present then return - 1 ; Driver Code
code: < ? php function linearSearch ( $ arr , $ n ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ arr [ $ i ] == $ i ) return $ i ; } return -1 ; } $ arr = array ( -10 , -1 , 0 , 3 , 10 , 11 , 30 , 50 , 100 ) ; $ n = count ( $ arr ) ; echo " Fixed ▁ Point ▁ is ▁ " . linearSearch ( $ arr , $ n ) ; ? >