This is not working correctly. When I look at $data I see that it task1 has the string "Task_0" instead of the value of Task_0. I am looking to log all the values into a table. My table has the structure attached. What is the easy way to do this? I realize that once I get it into the array I need to use $this->db->insert('activity_log',$data);
So I am trying to get data that came over from another app into my CI based program so I can log it to the database.
$json has two structures. The first ($json[0]) is the email address of this user. I can get that one fine. $json[1] is an array of two structures.
$Arr=(array)$json[1];
$Arr=array_values($Arr); //this is an array of two structures. The first is from the tasks array and the 2nd is from the Bus comp array.
Attached is the $Arr structure. As you can see, it is an array of two different sized structures. $Arr[0] is the tasks structure and $Arr[1] is the BusComps structure. My database tables have slightly different structures since I include a few other fields such as a timestamp. So how do I get these two structures into a form that I can db->insert() into one of those two tables?
Previously I had the data coming in from the other app in a string and I just used picked off the fields I needed. On this one, the data from the other app is coming in as a structure (actually two structures) but I can't seem to get the values. So foe example, $Arr[0].Task_0 should be the value of the Task_0 element of the structure in array[0]. It should be the string "{choose}". This is exactly what it is when I look at it with the debugger. But when I run $task0=$Arr[0].Task_0; $task0 is assigned "Task_0". How do I get the value of the element instead of the index name?
07-23-2018, 08:03 AM (This post was last modified: 07-23-2018, 08:05 AM by Pertti.)
Ah, $Arr[0] is an array?
I, for some stupid reason, assumed it was an object.
In that case $Arr[0]['Task_0'] should work, but probably best if you check what format and structure your array is with var_dump function.
Also noticed you have few extra . in the code right after -> that's probably why the code doesn't run. And you would need to use same method for all elements, not just for percent.