function takes an infinite size array and a key to be searched and returns its position if found else - 1. We don 't know size of arr[] and we can assume size to be infinite in this function. NOTE THAT THIS FUNCTION ASSUMES arr[] TO BE OF INFINITE SIZE THEREFORE, THERE IS NO INDEX OUT OF BOUND CHECKING
function findPos ( $ arr , $ key ) { $ l = 0 ; $ h = 1 ; $ val = $ arr [ 0 ] ;