Skip to content

Tag: arrays

Converting a database result of 3 columns to associative array

I have a MySQL query that returns the following result: I need to loop through the result and create a new associative array where the key is the ApptTime and the value is the combination of ApptType and Count like so: I’ve tried looping through the mysqli_fetch_assoc result in a variety of ways and cre…

Add JSON keys/values while creating another JSON PHP

I am trying to pass some JSON keys/values that I have to another JSON I am creating dynamically. For example, this is the JSON I have in $json_create That comes over file_get_contents And this is the JSON I am creating Which print something like What I am trying to achieve is There is quite a lot on that subj…

PHP – How do I add a name to an array

I am building an array (json encoded) and returning it to the caller. My output currently looks like this: I want to add a name so that output looks like this: Here is my current code: I am fairly new to OO coding, so I have not figured out how to initialize an object so that “orgs” is present. Ma…