"how to filter an array by a condition" Code Answer

$fullArray = array('a'=>2,'b'=>4,'c'=>2,'d'=>5,'e'=>6,'f'=>2);

function filterArray($value){
    return ($value == 2);

$filteredArray = array_filter($fullArray, 'filterArray');

foreach($filteredArray as $k => $v){
    echo "$k = $v";
By BartmanEH on December 20 2022

Answers related to “how to filter an array by a condition”

Only authorized users can answer the search term. Please sign in first, or register a free account.