I have an array result like this.
Array
(
[Bank] => Array
(
[name] => Bank
[status] => 1
[enable_rcb] => 1
)
[Cod] => Array
(
[name] => Cod
[status] => 1
[enable_rcb] => 0
)
[Lite] => Array
(
[name] => Lite
[status] => 0
[enable_rcb] => 0
)
)
I want to get result from conditional. For example I want show only Bank if the status is 1 and leave the rest array. I try to show them like this
$results = array();
foreach ($user_pay as $value) {
foreach ($value as $k => $v) {
if($value['status']=="1"){
$user_payment[] = $value['name'];
}
}
$results = $user_payment;
}
But the result give me duplicate result like this
Array
(
[0] => Bank
[1] => Bank
[2] => Bank
[3] => Bank
[4] => Bank
[5] => Bank
[6] => Cod
[7] => Cod
[8] => Cod
[9] => Cod
[10] => Cod
)
What I want is to get the name of an array which is have status 1 and it should be like this
Array
(
[0] => Bank
[1] => Cod
)
How to avoid this duplicate result?