title: Finding the Index while searching from an Array using in_array in PHP
body: <p>My aim is to find out what the operator is, and where it was in the original $operatorArray (which contains the various operators such as "+", "-" etc... ) </p>
  
  <p>So I have managed to check when $operator matches with another operator in my existing $operatorArray, however I need to know where in $operatorArray it is found. </p>
  
  <pre><code>foreach ($_SESSION['explodedQ'] as $operator){ //search through the user input for the operator. 
  
          if (in_array("$operator", $operatorArray)) { //if the operator that we found is in the array, then tell us what it is
  
              print_r("$operator"); //prints the operator found
              print_r("$positionNumber"); //prints where the operator is
  
          } //if operator 
          else{
  
              $positionNumber++; //The variable which keeps count on where the array is searching. 
          }
  </code></pre>
  
  <p>I've tried Google/Stack searching, but the thing is, I don't actually know what to Google search. I've searched for things like "find index from in_array" etc... and I can't see how to do it. If you could provide me with a simple way to understand how to achieve this, I would be greatful. Thanks for your time. </p>