I have array in php :
Array
    (
        [id] => 1
        [comp_id] => 1
        [transaction_purpose] => 0
        [source_of_funds] => 1
        [beneficiary_relationship] => 0
        [cus_occupation] => 0
        [cus_id_image_2] => 0
        [cus_id_image_3] => 0
        [ben_id_type] => 0
        [ben_id_number] => 1
    )
I want to get only array key=>value pair if the valie is 1.
result array should be:
Array
    (
        [id] => 1
        [comp_id] => 1
        [source_of_funds] => 1
        [ben_id_number] => 1
    )
I tried with:
$returnArray = array();
    foreach($mainArray as $r){
        if($r>0){
            array_push($returnArray, $mainArray);
        }
    }
But, It's giving me 4 times main array. Is there any way to achieve this? Thanks..
 
     
     
    