Bento
5 days ago

Check if a value from a nested array exists in another nested array

Posted 5 days ago by Bento

I have an array like this:

$mySeriesArr:

array (size=2)
  0 => 
    array (size=2)
      'id' => int 4
      'videos_id' => int 6
  1 => 
    array (size=2)
      'id' => int 3
      'videos_id' => int 22

I need to know if the value of 'videos_id' exists as the value 'id' in this array example.

$allSeriesArr:

  0 => 
    array (size=17)
      'id' => int 6
      'type' => int 0
      'title' => string 'Showname 1' (length=11)
  1 => 
    array (size=17)
      'id' => int 8
      'type' => int 0
      'title' => string 'Showname 2' (length=11)

I can do it with a SQL join but then (for other reasons) I cannot cache the result as it's different for each user. That's why I split it into 2 queries and want to compare them in code.

Anyway, I must be dumb but I cannot figure this out in a clean way (or at all).

Any ideas?

Please sign in or create an account to participate in this conversation.