title: PHP - if a value exists in an array of objects
body: <p>I have an array of objects called $filtes which goes as follows:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [title] =&gt; Type
              [alias] =&gt; type
              [id] =&gt; 14
              [parent_id] =&gt; 9
              [subs] =&gt; Array
                  (
                      [0] =&gt; stdClass Object
                          (
                              [title] =&gt; car
                              [alias] =&gt; car
                              [id] =&gt; 15
                              [parent_id] =&gt; 14
                          )
  
                  )
  
          )
  
      [1] =&gt; stdClass Object
          (
              [title] =&gt; Model
              [alias] =&gt; model
              [id] =&gt; 18
              [parent_id] =&gt; 9
              [subs] =&gt; Array
                  (
                      [0] =&gt; stdClass Object
                          (
                              [title] =&gt; XF
                              [alias] =&gt; xf
                              [id] =&gt; 19
                              [parent_id] =&gt; 18
                          )
  
                      [1] =&gt; stdClass Object
                          (
                              [title] =&gt; XJ
                              [alias] =&gt; xj
                              [id] =&gt; 20
                              [parent_id] =&gt; 18
                          )
  
                      [2] =&gt; stdClass Object
                          (
                              [title] =&gt; XK
                              [alias] =&gt; xk
                              [id] =&gt; 21
                              [parent_id] =&gt; 18
                          )
  
                      [3] =&gt; stdClass Object
                          (
                              [title] =&gt; F-TYPE
                              [alias] =&gt; f-type
                              [id] =&gt; 22
                              [parent_id] =&gt; 18
                          )
  
                  )
  
          )
  
      [2] =&gt; stdClass Object
          (
              [title] =&gt; Condition
              [alias] =&gt; condition
              [id] =&gt; 24
              [parent_id] =&gt; 9
              [subs] =&gt; Array
                  (
                      [0] =&gt; stdClass Object
                          (
                              [title] =&gt; new
                              [alias] =&gt; new
                              [id] =&gt; 24
                              [parent_id] =&gt; 9
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>What is the best practice to check if a word exists in $filters[$i]->title and $filters[$i]->subs[$j]->title. Speed is really important in this checking.</p>