title: Get index of value from an array in php
body: <p>I have the below php array <code>$tempStyleArray</code> which is created by spiting a string.</p>
  
  <pre><code>$tempStyleArray = preg_split( "/[:;]+/", "width: 569px; height: 26.456692913px; margin: 0px; border: 2px solid black;" );
  
  
  Array
  (
      [0] =&gt; width
      [1] =&gt;  569px
      [2] =&gt;  height
      [3] =&gt;  26.456692913px
      [4] =&gt;  margin
      [5] =&gt;  0px
      [6] =&gt;  border
      [7] =&gt;  2px solid black
      [8] =&gt; 
  )
  </code></pre>
  
  <p>I have to get <code>index/key</code> of the element <code>height</code> from this array. I tried below codes but nothing seems to be working for me. </p>
  
  <pre><code>foreach($tempStyleArray as  $value)
  {
     if($value == "height") // not satisfying this condition
     {
       echo $value;
       echo '&lt;/br&gt;';
       $key = $i;
     }
  } 
  </code></pre>
  
  <p>in above solution it not satisfying the condition ever :(</p>
  
  <pre><code>$key = array_search('height', $tempStyleArray); // this one not returning anything
  </code></pre>
  
  <p>Help me to solve this? Is there any problem with my array format?</p>