0

If I have an array in the following format:

Array (
    [0] => Array (
        [0] => Array (
            [count(*)] => 7
        )
    )
    [1] => Array (
        [0] => Array (
            [count(*)] => 1
        )
    )
    [2] => Array (
        [0] => Array (
            [count(*)] => 1
        )
    )
) 

How can I return it as the format below:

# What I need to capture into the new array:
# [count(*)] => 7 , [count(*)] => 1, [count(*)] => 1 
# So the values would be summed from the sub-arrays:
# 7+1+1 = 9
# The array would end up with just one value in it which is the sum
Array(
    [0] => 9
)

I just want to get the total count from that array, any ideas?

Rasclatt
  • 12,498
  • 3
  • 25
  • 33
maxqin
  • 1
  • 3
  • Can you be more specific about how you're trying to change the format? Maybe use actual PHP code? If you're trying to sum the values of the `count(*)` keys, the result would be 9, not 10. If that's not what you're trying to do, it's unclear what is. – Don't Panic May 05 '17 at 17:02
  • 1
    Do you have any code of your own to show what you have tried so far? The folks here will help you with your code, but will not be writing it for you. – Crackertastic May 05 '17 at 17:03
  • sorry, that's my bad. i am trying to sum the values of the count(*) – maxqin May 05 '17 at 17:08
  • 2
    Possible duplicate of http://stackoverflow.com/questions/1496682/how-to-sum-values-of-the-array-of-the-same-key – Don't Panic May 05 '17 at 17:12

0 Answers0