Find final value if we double after every successful search in array | Function to Find the value of k ; Search for k . After every successful search , double k . ; Driver Code
< ? php function findValue ( $ arr , $ n , $ k ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) if ( $ arr [ $ i ] == $ k ) $ k *= 2 ; return $ k ; } $ arr = array ( 2 , 3 , 4 , 10 , 8 , 1 ) ; $ k = 2 ; $ n = count ( $ arr ) ; echo findValue ( $ arr , $ n , $ k ) ; ? >