I'm having a hard time drawing a array
in PHP
with the following data coming from a JSON
object, no, it does not come from a SQL query in a database.
Example of JSON
:
[
{
"data": {
"ID": "349",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-22 12:46:35",
"user_activation_key": "",
"user_status": "0",
"display_name": "Antonio Carlos Braga"
},
"ID": 349,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "292",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-21 02:19:11",
"user_activation_key": "",
"user_status": "0",
"display_name": "Adriana Cristina Alves da Silva"
},
"ID": 292,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "196",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Facebook",
"user_registered": "2018-03-20 14:28:58",
"user_activation_key": "",
"user_status": "0",
"display_name": "Adriana Fernandes de oliveira"
},
"ID": 196,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "286",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-21 01:19:53",
"user_activation_key": "",
"user_status": "0",
"display_name": "Alexandre Ramos de Campos"
},
"ID": 286,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "225",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-20 17:55:09",
"user_activation_key": "",
"user_status": "0",
"display_name": "Alex miguins de lima"
},
"ID": 225,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "318",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-21 14:35:38",
"user_activation_key": "",
"user_status": "0",
"display_name": "Alexandra Alves Ferreira"
},
"ID": 318,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "188",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-20 13:21:28",
"user_activation_key": "",
"user_status": "0",
"display_name": "Analucia c g pedreira"
},
"ID": 188,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "216",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Facebook",
"user_registered": "2018-03-20 16:56:12",
"user_activation_key": "",
"user_status": "0",
"display_name": "ANDREZA AP TOLEDO"
},
"ID": 216,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "299",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-21 05:39:16",
"user_activation_key": "",
"user_status": "0",
"display_name": "angela maria de queiroz"
},
"ID": 299,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "291",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-21 02:15:56",
"user_activation_key": "",
"user_status": "0",
"display_name": "Angelica dos Santos Marques"
},
"ID": 291,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "224",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"user_registered": "2018-03-20 17:47:14",
"user_activation_key": "",
"user_status": "0",
"display_name": "Adilson Nicanor de Assis"
},
"ID": 224,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "190",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Facebook",
"user_registered": "2018-03-20 13:39:58",
"user_activation_key": "",
"user_status": "0",
"display_name": "António Carlos Bomfim Barros"
},
"ID": 190,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
},
{
"data": {
"ID": "359",
"user_login": "###",
"user_pass": "###",
"user_nicename": "###",
"user_email": "###",
"user_url": "",
"source": "Google",
"user_registered": "2018-03-23 01:23:08",
"user_activation_key": "",
"user_status": "0",
"display_name": "Marizete De Souza Lobato"
},
"ID": 359,
"caps": {
"subscriber": true
},
"cap_key": "gc_capabilities",
"roles": [
"subscriber"
],
"allcaps": {
"read": true,
"level_0": true,
"subscriber": true
},
"filter": null
}
]
That translated into a table would be:
| Fonte | Data de cadastro |
|----------|------------------|
| Google | 21/03/2018 |
| Google | 22/03/2018 |
| Facebook | 21/03/2018 |
| Facebook | 22/03/2018 |
| Google | 23/03/2018 |
| Facebook | 21/03/2018 |
| Google | 21/03/2018 |
| Google | 22/03/2018 |
Manually counting I know that on 21/03/2018 I had 2 Google signups and 2 Facebook signups, 03/22/2018 I had 1 Google signup and 1 Facebook signup, and so on
I'd like to generate a array
that I believe to be associative to generate a table like this after a loop
:
| Fonte | Data de cadastro | Total de cadastros |
|----------|------------------|--------------------|
| Google | 21/03/2018 | 2 |
| Facebook | 21/03/2018 | 2 |
| Facebook | 22/03/2018 | 1 |
| Facebook | 22/03/2018 | 1 |
| Google | 23/03/2018 | 1 |
I also know that this sum can be obtained with a function to add the values of array
but I can not "draw" that array
.