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

php数组里数值相加

WBOY
Release: 2016-06-06 20:09:52
Original
2561 people have browsed it

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

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

回复内容:

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

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

<code>echo array_sum(array_column($your_array, 'number'));</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template