-1

I have two different arrays with the same delivery_type_id

Array 1:

Array
(

    [0] => Array
        (
            [delivery_type_id] => 2
            [delivery_code] => InStorePickup
            [delivery_title] => In Store Pickup
        )

    [1] => Array
        (
            [delivery_type_id] => 3
            [delivery_code] => On-FarmPickup
            [delivery_title] => On-Farm Pickup
        )
)

Array 2:

Array
(

    [0] => Array
        (
            [delivery_type_id] => 2
        )

)

I need the common delivery_type_id from the array as follow

Result:

Array (

    [0] => Array
        (
            [delivery_type_id] => 2
            [delivery_code] => InStorePickup
            [delivery_title] => In Store Pickup
        )
)

I have tried array_intersect() with array_column but, it's not working. Thanks in advance.

Alok Kumar
  • 25
  • 5
  • Does this answer your question? [How to get common values from two different arrays in PHP](https://stackoverflow.com/questions/17648962/how-to-get-common-values-from-two-different-arrays-in-php) – Hkachhia Sep 21 '21 at 09:40
  • No, it's not working. – Alok Kumar Sep 21 '21 at 09:42

1 Answers1

0

Loop through them and compare.

foreach($array0 as $a){
 foreach($array1 as $b){
  if($a['delivery_type_id']==$b['delivery_type_id']){ do things }
 }
}
Tomaac
  • 64
  • 5