Home >Backend Development >PHP Tutorial >php数组里数值相加

php数组里数值相加

WBOY
WBOYOriginal
2016-06-06 20:09:522581browse

里边的数值相加,用array_sum()不行,有最合适的办法吗

<code>[
  {
    "number": "105"
  },
  {
    "number": "105"
  },
  {
    "number": "105"
  },
  {
    "number": "105"
  }
]</code>

回复内容:

里边的数值相加,用array_sum()不行,有最合适的办法吗

<code>[
  {
    "number": "105"
  },
  {
    "number": "105"
  },
  {
    "number": "105"
  },
  {
    "number": "105"
  }
]</code>

<code>echo array_sum(array_column($your_array, 'number'));</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn