How to remove index of an array for specific match in php
127
The array$results
has the following values. I want to remove the index of array$results
if[total_ex_tax]
has negative value. Need your support.
Array
(
[0] => Array
(
[service_number] => 1300468746
[total_ex_tax] => 28850.439453125
[bill_date] => 2016-03-14 00:00:00
[l1] => HNSW
[l2] => Contact Centre
[l3] => 3350
[l4] => 71603
[l5] =>
[l6] => OneFACS
[levelcount] => 4
[l1_name] => Division
[l2_name] => District
[l3_name] => Cost Centre
[l4_name] => Code
[l5_name] =>
[l6_name] =>
[function_name] => Inbound
[type] => 1300 Service
[features] =>
[application] =>
[name] => Unknown
[city] => Unknown
[username] => HNSW 1300 Inbound
)
[1] => Array
(
[service_number] => 0297162222
[total_ex_tax] => -214.529296875
[bill_date] => 2016-03-07 00:00:00
[l1] => CS
[l2] => CS Central Office
[l3] => 916
[l4] => 1002
[l5] =>
[l6] => OneFACS
[levelcount] => 4
[l1_name] => Division
[l2_name] => District
[l3_name] => Cost Centre
[l4_name] => Code
[l5_name] =>
[l6_name] =>
[function_name] => Cisco VoIP
[type] => ISDN 120
[features] => SIP F2M
[application] => DCAshfield_CSAS1_DP
[name] => Ashfield CS Head Office
[city] => Ashfield
[username] =>
)
[2] => Array
(
[service_number] => 1800152152
[total_ex_tax] => 16897.69921875
[bill_date] => 2016-03-14 00:00:00
[l1] => HNSW
[l2] => Contact Centre
[l3] => 3350
[l4] => 71600
[l5] =>
[l6] => OneFACS
[levelcount] => 4
[l1_name] => Division
[l2_name] => District
[l3_name] => Cost Centre
[l4_name] => Code
[l5_name] =>
[l6_name] =>
[function_name] => Inbound
[type] => 1800 Service
[features] =>
[application] =>
[name] => Liverpool Housing
[city] => Liverpool
[username] =>
)
)
Answer
Solution:
Try following code:
You need to use combination of array_filter and array_map
Answer
Solution:
Try this:
Answer
Solution:
You can try this:
Result:
Answer
Solution:
haven't checked it. TRY IT OUT :
Answer
Solution:
Short solution with
array_filter
function: