Using a last element as search element
$ key = 40 ; $ position = findElement ( $ arr , $ n , $ key ) ; if ( $ position == - 1 ) echo ( " Element ▁ not ▁ found " ) ; else echo ( " Element ▁ Found ▁ at ▁ Position : ▁ " . ( $ position + 1 ) ) ; ? >