Questions tagged [array-intersect]

PHP's array_intersect() function accepts the array with master values to check, an array to compare values against and a variable list of arrays to compare. It returns an array containing all of the values in master array whose values exist in all of the parameters.

PHP's array_intersect() function accepts the array with master values to check, an array to compare values against and a variable list of arrays to compare. It returns an array containing all of the values in master array whose values exist in all of the parameters.

169 questions
-3
votes
1 answer

get array elements which have key in second array in php

I need only array elements which have their keys in values of second array, with the fastest script. $array_1 = array( 'ana' => 'are', 'du' => 34, 'bopq'=> "Ana are mere mereu", 13 => "OK" ); $array_2 = array('du',…
Arșavin
  • 17
  • 6
-3
votes
2 answers

Given two arrays, how to build a new array that includes only elements of one array which keys are present in the second array as values?

I've the following two arrays: // array1 Array ( [key1] => value1, [key2] => value2, [key3] => value3, [key4] => value4, [key5] => value5 ) // array2 Array ( [0] => key1, [1] => key3, [2] => key5 ) I would like to build a new array that…
Backo
  • 18,291
  • 27
  • 103
  • 170
-4
votes
4 answers

how coding to check the data with array Intersect?

I wanted to check to enter data into the database.Checks are as follows $implode1 = "apple, orange, banana"; $implode2 = "banana, mango"; If the banana in the variable $implode1 is also contained in the variable $implode2, it should display a…
user1798945
  • 145
  • 1
  • 2
  • 7
-5
votes
2 answers

Filter 2D array using another 2D array where differently keyed column values intersect

I have an array like this: $array1 = [ [ 'Firepack_sn' => '20012205', 'Installation_Date' => '', 'Type' => 'EH', 'Capacity_m3h' => '81', 'Pressure_bar' => '3,4', 'Rpm' => '2930', 'Power_kw'…
DNC
  • 443
  • 1
  • 6
  • 20
1 2 3
11
12