how can I search an array matching two or more values?
Array
(
    [1440972000] => Array
        (
            [mitarbeiterid] => 1
            [von] => 1441006800
            [doppeltermin] => n
            [stundentermin] => n
            [abgesagt] => n
        )
)
I would like to search for "mitarbeiterid" and "von". This is just a example, in this array are a few hundred entries.
I only know how to search for e.g. "von" but how to combine the search parameters?
Have a look at array_filter()
$filtered_array = array_filter($your_array, function($val){
              return ($val['mitarbeiterid']=='something' and $val['von']=='something');
          });
To use outside variables, inside lambda function, use use keyword
$var1 = 'something';
$var2 = 'something';
//                                                         ▼
$filtered_array = array_filter($your_array, function($val) use($var1, $var2){
    return ($val['mitarbeiterid']==$var1 and $val['von']==$var2);
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With