Skip to content
Advertisement

How to sum up property string length by ID using PHP in a JSON array

I am trying to sum up the character count(total string length) of all the characters contained in the various “info” properties by “user_id”. I am trying to have a situation where USER-ID A001 has 300 total characters in INFO

I am hoping someone can point me in the right direction.

Below is my code snippet:

JavaScript

MY PHP

JavaScript

Advertisement

Answer

Use an associative array to hold the results, with the user_id values as the keys.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement