php - Sorting out rows with same timestamp -
i have mysql table has key, value , timestamp in it. data comes form , every field adds key value pair , of them have same timestamp. come out :
[0] => array ( [key] => name [value] => john [timestamp] => 2016-02-08 14:16:00 ) [1] => array ( [key] => email [value] => john$john.com [timestamp] => 2016-02-08 14:16:00 ) [2] => array ( [key] => name [value] => guru [timestamp] => 2016-02-08 14:16:05 ) [3] => array ( [key] => email [value] => test@gmail.com [timestamp] => 2016-02-08 14:16:05 )
what take key-value pairs same timestamp , print them out in 1 row , next timestamp in next row. im using php.
thanks :)
you'll want store timestamp check against on next pass.
$previous = null; foreach ($array $item) { if ($previous == $item['timestamp']) { // on same row have 1 this. } else { // on new row it's first of kind. } // save timestmap use on next pass of loop. $previous = $item['timestamp']; }
hopefully gives somewhere start from.
Comments
Post a Comment