Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP looping through a nested array.. BUT: [closed]

Tags:

php

I have an array with 3 values: time, sensor1, sensor2

Each of those 3 contain the exact same ammount of additional values.

I would like to loop through a specific one, for example time and only get those values.

I recon with foreach I would have to go through all of the 3? Something like this (it didnt work it seems, thats why im asking):

foreach($datacollection as $valuearray)
    {
    $string .= "'" . $valuearray['time'] . "',";
    }

I hope you understand what I'd like to do!

like image 563
Jrc Avatar asked Mar 05 '26 20:03

Jrc


1 Answers

try:

foreach ($datacollection['time'] as $value) {
    echo 'value is ' . $value;
}

is that what you want to achieve?

like image 89
yacon Avatar answered Mar 07 '26 10:03

yacon