Welcome Guest, Not a member yet? Register   Sign In
Unable to add to array
#1
Question 
(This post was last modified: 06-15-2022, 03:53 PM by Sincere.)

I've done this many times before: adding an array to an yet already existing array, but for some reason this isn't working now, and I'm out of clues:
PHP Code:
$influx_server_data = [];
$stats = [
                    'health'        =>  $health,
                    'total_live'    =>  $server->live_total,
//etc etc/
                    'mem_used'      =>  $server->system_stats->memory->used,
                    'mem_total'      =>  $server->system_stats->memory->total,
                ];
                $servers_model->update($live_server->id,$stats);

                //Influx Magic

                // Server influx data
                foreach($stats as $measurement => $value){
                    $influx_server_point = [$measurement//name of measurement
                        $value//measurement value
                        ['host' => $live_server->hostname'region' => $live_server->region], // optional tags
                        $now
                    
];
                    print_r($influx_server_point);
                    $influx_server_data $influx_server_data + [$influx_server_point];
                }
                print_r($influx_server_data); 

But for some reason $influx_server_data will only have the array from the first run (health in this case). The first print_r confirms that the foreach works fine and shows the desired array for each run.
I'd be grateful for any insights!
Reply


Messages In This Thread
Unable to add to array - by Sincere - 06-15-2022, 03:52 PM
RE: Unable to add to array - by Sincere - 06-15-2022, 09:20 PM
RE: Unable to add to array - by InsiteFX - 06-16-2022, 12:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB