title: Finding the index of a given value in a pre-sorted array
body: <p>Today, I went for an interview and the interviewer asked me how I would find the index of a given value (number) in a pre-sorted array like this:</p>
  
  <pre><code>$preSortedArr=array(23,32,36,41,45,54);
  </code></pre>
  
  <p>He also said that using recursion is not allowed.</p>
  
  <p>I think the function should look like this:</p>
  
  <pre><code>function findIndexByValue($preSortedArray,$value){            
  //some codes here       
  }
  </code></pre>
  
  <p>What solution do you think he was expecting from me?</p>
  
  <p><strong>EDIT:</strong> Sorry, I forgot to add that he originally asked me to write pseudocode, but I said I didn't know. Then I tried to write it in PHP, but I think he's expecting a language-independent solution.</p>