# Getting an array instead of number

**URL:** <https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016>\
**Category:** Need Help\
**Created:** [September 28, 2018, 6:27am UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016 "2018-09-28T06:27:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnadel88](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@johnadel88](https://discourse.cakephp.org/u/johnadel88)\
**Post date:** [September 28, 2018, 6:27am UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016/1 "2018-09-28T06:27:13Z")

</div>

Hello everybody,  
I’m doing some changes on a clients website but i’m not experienced php developer.  
I’m trying to get total of values of a column called “amount” in a table called “withdraws”  
I have this code:

$totalWithdrawls = $this-\>Users-\>Withdraws-\>find()-\>sumOf(‘amount’);

Which return the content as an array (5,10,15,20)  
I want to get the total of them (50) as a number.  
how to achieve that?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [September 29, 2018, 10:35am UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016/2 "2018-09-29T10:35:48Z")

</div>

[http://php.net/manual/en/function.array-sum.php](http://php.net/manual/en/function.array-sum.php)

---

<div class="post-metadata">

**Author:** ![johnadel88](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@johnadel88](https://discourse.cakephp.org/u/johnadel88)\
**Post date:** [September 29, 2018, 11:53am UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016/3 "2018-09-29T11:53:18Z")

</div>

Thank you sir, my code worked perfectly with no changes at all !!!  
I do not know what happened yesterday!!

---

<div class="post-metadata">

**Author:** ![FinlayDaG33k](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/finlaydag33k/32/1049_2.png) [@FinlayDaG33k](https://discourse.cakephp.org/u/FinlayDaG33k)\
**Post date:** [September 30, 2018, 4:29pm UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016/4 "2018-09-30T16:29:32Z")

</div>

Sounds like some kind of cache (eg. OPCache) might have been causing this error? 🙂

---

<div class="post-metadata">

**Author:** ![johnadel88](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@johnadel88](https://discourse.cakephp.org/u/johnadel88)\
**Post date:** [September 30, 2018, 4:40pm UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016/5 "2018-09-30T16:40:57Z")

</div>

To be honest, i have no idea what happened exactly !!!

---

<div class="post-metadata">

**Author:** ![FinlayDaG33k](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/finlaydag33k/32/1049_2.png) [@FinlayDaG33k](https://discourse.cakephp.org/u/FinlayDaG33k)\
**Post date:** [September 30, 2018, 4:45pm UTC](https://discourse.cakephp.org/t/getting-an-array-instead-of-number/5016/6 "2018-09-30T16:45:30Z")

</div>

Ah yes, the programmer dillemma: “it doesn’t work, I have no clue why; it works, I have no clue why”
