i got this json format form form-builder plugin, in hope someone could help out i need to count the number of times certain fields occur so i can create a database for them
[ { "cssClass" : "checkbox",
"required" : "false",
"title" : "hello save",
"values" : { "2" : { "baseline" : "false",
"value" : "save"
},
"3" : { "baseline" : "false",
"value" : " save 2"
},
"4" : { "baseline" : "false",
"value" : "save 3"
},
"5" : { "baseline" : "false",
"value" : "save 4"
},
"6" : { "baseline" : "false",
"value" : "save 5 "
},
"7" : { "baseline" : "false",
"value" : "Save 6"
}
}
},
{ "cssClass" : "textarea",
"required" : "false",
"values" : "you did not say hello properly"
},
{ "cssClass" : "checkbox",
"required" : "false",
"title" : "whats up save",
"values" : { "2" : { "baseline" : "false",
"value" : "i got your back"
},
"3" : { "baseline" : "false",
"value" : "i got your back 2"
},
"4" : { "baseline" : "false",
"value" : "i got your back 3"
},
"5" : { "baseline" : "false",
"value" : "1 got your back 4"
},
"6" : { "baseline" : "false",
"value" : "i got your back 5"
}
}
}
]
i want to be able to count the number of cssClass checkbox and the corresponding values value to help create a database table for insert in mysql or mongodb i will like it in a format like this
count($data[cssclass])
count($data[cssClass][values])
i get
Notice: Undefined index: cssClass in C:\wamp\www\callmeepo\index.php on line 45
i will appreciate any solution in php or nodejs sice am quite new to Json
!============================================================================! Hello guys, thanks for your timely response, i appreciate and feel very privileged to have u guy but it didn't really solve the challenge maybe i was not clear enough so this is the program logic. for the given json data i will like to sort it in a way that i can get the tile of the checkbox and its values which to create database entries for the user e.g for array with checkbox get title and number of values (value) so i can have something like say checkbox1 title values = 6 checkbox2 title values = 5