I am trying to allow an android user to replace a database table. My app reads in a excel spreadsheet from the phone, adds each row into a json, and then serializes the json to get a string:
[{"name":"catheter","alts":"cathater, cathiter, cath","num":"134"},
{"name":"cast","alts":"","num":"2212"}]
My app then sends the serializes json to a php file on my server where I
var_dump(json_decode($serializedString));
to get to the array in question:
array(2) { [0]=> object(stdClass)#2 (4) { ["name"]=> string(8)
"catheter" ["alts"]=> string(24) "cathater, cathiter, cath"
["num"]=> string(3) "134" } [1]=> object(stdClass)#3 (4) {
["name"]=> string(4) "cast" ["alts"]=> string(0) ""
["number"]=> string(0) "" }}
I'm php stupid, but I have tried a BUNCH of stuff. This will tell me how many items there are in the array:
$count = 0;
$something = json_decode($serializedJsonString, true);
foreach($something as $obj){
$count = $count+1;
}
echo $count;
I really need to be able to refer to each items key-value pairs so I can add them to a database which has columns for name, alt_names, and number. Thanks a bundle.