Search , insert and delete in an unsorted array | Function to implement search operation ; Driver Code ; Using a last element as search element
< ? php function findElement ( $ arr , $ n , $ key ) { $ i ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) if ( $ arr [ $ i ] == $ key ) return $ i ; return -1 ; } $ arr = array ( 12 , 34 , 10 , 6 , 40 ) ; $ n = sizeof ( $ arr ) ; $ key = 40 ; $ position = findElement ( $ arr , $ n , $ key ) ; if ( $ position == - 1 ) echo ( " Element ▁ not ▁ found " ) ; else echo ( " Element ▁ Found ▁ at ▁ Position : ▁ " . ( $ position + 1 ) ) ; ? >