There is a variable $ A with a value of 5 or 3. or there is a variable $ b with some value.
How to learn without busting in the cycle, i.e. Without third-party functions, whether the value of the variable $ A coincides with any element of the $ ARR array over the ‘A’ field. The same with the variable $ B? Something like in_array () or array_search ().
Answer 1, Authority 100%
You can use the Array_Column to get an array of the values of the desired speaker For example
$ a = 3;
if (in_array ($ a, array_column ($ arr, 'a'))) {
Echo 'Yes';
}
Answer 2
Option for PHP & LT; = 5.4
$ arr = array (
array ('a' = & gt; 2, 'b' = & gt; 15),
array ('a' = & gt; 3, 'b' = & gt; 15),
array ('a' = & gt; 4, 'b' = & gt; 2),
array ('a' = & gt; 8, 'b' = & gt; 3),
array ('a' = & gt; 15, 'b' = & gt; 1),
);
// The desired value
$ srch = 15;
Array_Filter ($ ARR, FUNCTION ($ A) USE (& amp; $ int, $ srch) {
Return (Array_Search ($ srch, $ a))? ++ $ int: false;
});
// Number of coincidences
Echo ($ int? $ int: 0); // 3