Jump to content

smith.james0

Members
  • Content Count

    124
  • Joined

  • Last visited

Community Reputation

0 Neutral

About smith.james0

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. Hi, The arrays come from three sql queries. I have already combined two which output to a graph to show temperature over a 24 hour period, now I have added another temperature probe and I want to add the third array to the existing one. I don't know a way of querying the db to produce a array like this Array ( [0] => Array ( [0] => 6 (Hour from db) [1] => 12.25000000000000 (Temp probe 1) [2] => 14.50000000000000 (Temp probe 2) [3] => 11.00000000000000 (Temp probe 3) ) etc etc.. Regards
  2. Hi, It's been a few years since i've done any php coding and it seams like I have forgotten how to combine 2 arrays! I am trying to combine This .... Array ( [0] => Array ( [0] => 6 [1] => 12.25000000000000 [2] => 14.50000000000000 ) [1] => Array ( [0] => 7 [1] => 12.43700000000000 [2] => 13.12500000000000 ) } etc, etc and this .... Array ( [6] => 11.00000000000000 [7] => 11.31200000000000 [17] => 14.18700000000000 } etc etc to make ... Array ( [0] => Array ( [0] => 6 [1] => 12.25000000000000 [2] => 14.50000000000000 [3] => 11.00000000000000 ) [1] => Array ( [0] => 7 [1] => 12.43700000000000 [2] => 13.12500000000000 [3] => 11.31200000000000 ) [2] => Array ( [0] => 17 [1] => 16.12500000000000 [2] => 15.75000000000000 [3] => 14.18700000000000 ) } I've tried $out2 = array(); foreach ($out as $value){ $out2[] = array_merge($value, array($water[$key])); } but this seams to alter the value of the combined array value in the 3rd key. Can anyone point to what I have done wrong? Regards
  3. I have only just got round to changing it, thanks
  4. Thanks, do you have any ideas how I could check my array so the hour matches the array key? James
  5. Hi, I am sure that the solution is easy but it's flummoxed me! I have a python script that sometimes doesn't record the temperature so I end up with 23 readings instead of 24 per day, or less. My php script reads the date from the db and puts it into a array to use in a graph. My problem is that I need to check the correct temperature reading go with the correct hour of the day. Array ( [0] => Array ( [0] => 00 [1] => 4.30 ) [1] => Array ( [0] => 01 [1] => 4.30 ) [2] => Array ( [0] => 02 [1] => 4.10 ) [3] => Array ( [0] => 03 [1] => 4.00 ) [4] => Array ( [0] => 05 [1] => 3.70 ) etc etc.. Above [0][0] is the time and [0][1] is the temperature, what I need is for the time to match the array key. So in [4][0] the time is 05 but the key is 04 i.e... Array ( [0] => Array ( [0] => 00 [1] => 4.30 ) [1] => Array ( [0] => 01 [1] => 4.30 ) [2] => Array ( [0] => 02 [1] => 4.10 ) [3] => Array ( [0] => 03 [1] => 4.00 ) [4] => Array ( [0] => 04 [1] => ) [5] => Array ( [0] => 05 [1] => 3.70 ) This is the code I use to make the array while($row = $result->fetch_array()) { $inside[] = $row; $date = strtotime($inside[$i][Time]); $inside[$i][4] = date('G', $date); $inside[$i][2] = $inside[$i][0]; unset($inside[$i][Temp]); unset($inside[$i][Time]); unset($inside[$i][1]); unset($inside[$i][0]); ++$i; } I can get it to check the time against the key, but I can not get it to correct the key to the time. Can anyone help?? Many thanks James
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.