title: php recursion global variable?
body: <p>I have a recursion function that parses an object/array with a global variable. If I comment out the global variable I get nothing but if I leave it in it keeps adding to the array other values that should be in it own result set. Do I need to change something here?</p>
  
  <p>UPDATE #2:
  How can I get the return I want, I thought I was pushing all unique values to the array?</p>
  
  <pre><code>function getResp($objectPassed) {
  
      foreach($objectPassed as $element) {
          if(is_object($element)) {
              // recursive call
              $in_arr = getResp($element);
          }elseif(is_array($element)) {
              $in_arr = getResp($element);
          } else {
              // XML is being passed, need to strip it
              $element = strip_tags($element); 
  
              // Trim whitespace
              $element = trim($element);
  
              // Push to array
              if($element != '') {
                  if (!preg_match("/^[0-9]$/", $element)) {
                      if (!in_array($element,$in_arr)) {
                          $in_arr[] = $element;
                      }
                  }
              } 
          }
      }
      return $in_arr;
  }
  </code></pre>
  
  <p>INPUT:</p>
  
  <pre><code>stdClass Object
  (
      [done] =&gt; 1
      [queryLocator] =&gt;
      [records] =&gt; Array
          (
              [0] =&gt; stdClass Object
                  (
                      [type] =&gt; typeName
                      [Id] =&gt; Array
                          (
                              [0] =&gt; a0E50000002jxhmEAA
                              [1] =&gt; a0E50000002jxhmEAA
                          )
  
                  )
  
              [1] =&gt; stdClass Object
                  (
                      [type] =&gt; typeName
                      [Id] =&gt; Array
                          (
                              [0] =&gt; a0E50000002jxYkEAI
                              [1] =&gt; a0E50000002jxYkEAI
                          )
  
                  )
  
          )
  
      [size] =&gt; 2
  )
  </code></pre>
  
  <p>RETURN:</p>
  
  <pre><code>Array
  (
      [0] =&gt; a0E50000002jxYkEAI
  )
  </code></pre>
  
  <p>WANTED RETURN:</p>
  
  <pre><code>Array
  (
      [0] =&gt; a0E50000002jxYkEAI
      [1] =&gt; a0E50000002jxhmEAA
  )
  </code></pre>