title: PHP - Find string in an Object
body: <p>Want to find a string in an object, found this code online, but doesn't seem to work off-the-shelf, so to speak:</p>
  
  <pre><code>private static function in_object($val, $obj) {
      if($val == ""){
          trigger_error("in_object expects parameter 1 must not empty", E_USER_WARNING);
          return false;
      }
      if(!is_object($obj)){
          $obj = (object)$obj;
      }
  
      foreach($obj as $key =&gt; $value){
          if(!is_object($value) &amp;&amp; !is_array($value)){
              if(strpos($value,$val)!==FALSE){
                  return true;
              }
          }elseif(is_array($value)) {
             if(in_array($val, $value)!==FALSE){
                  return true;
              }
          }else{
              return self::in_object($val, $value);
          }
      }
      return false;
  }
  </code></pre>
  
  <p>It does not return an error message, the screen simply stays blank. The object I am searching will include arrays, and it is one of the arrays that I want test for certain text strings. </p>
  
  <p>Was hoping this had a minor error and could be easily fixed.  Or perhaps some other solution?</p>