PHP function to find certain values in an array, then execute code
<p>So I am trying to check to see if this array has an underscore in it. I am not sure if I am using the correct function to do this. Any input would be appreciated.</p>

<p>Some more info, if the array does have an underscore I want it to run the code below. This code seperates and gives me the attributes that I want. I also check if it has and S and then run some code. These are all output to queries which are then queried at the end.</p>

<pre><code>    if (count($h)==3){
           if (strpos($h[2], '_') !== false)  // test to see if this is a weird quiestion ID with an underscore
               {
                    if (strpos($h[2], 'S') !== false)
                    {
                     // it has an S
                     $underscoreLocation = strpos($h[2], '_');
                     $parent = substr($h[2], 0, $underscoreLocation - 6); // start at beginning and go to S
                     $title = substr($h[2], $underscoreLocation - 5, 5);
                     $questions = "select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and parent_qid =".$parent." and title =".$title.";";
                    }
                    else
                    {
                     // there is no S
                     $underscoreLocation = strpos($h[2], '_');
                     $parent = substr($h[2], 0, $underscoreLocation - 2);
                     $title = substr($h[2], $underscoreLocation - 1, 1);
                     $questions = "select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and parent_qid =".$parent." and title =".$title.";";
                    }    
               }

           else
           {
            $questions = "select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and qid =".$h[2].";";
           }
</code></pre>
