alwoodman Posted February 22, 2010 Share Posted February 22, 2010 Im trying to get the days tide information which is currently in the array $tides to echo out as part of a string $message $tides = array(); do { $newtideheight = round($row_TidesFeed['Height'] + 3, 0); $basedate = strtotime($row_TidesFeed['Time']); $date1 = strtotime("-1 hour", $basedate); $newdate = substr(date('H:i:s', $date1), 0, 5); array_push($tides, rtrim($row_TidesFeed['State'], "W").''.$newdate); } while ($row_TidesFeed = mysql_fetch_assoc($TidesFeed)); // This is what i need to echo ideally as one variable $alltides which will sit at the end of and be part of the $message.''.$alltides foreach ($tides as $value){ echo $value; } $message = $message.' and the tides are $alltides'; thanks Lee Link to comment https://forums.phpfreaks.com/topic/192954-getting-array-items-into-one-variable/ Share on other sites More sharing options...
JonnoTheDev Posted February 22, 2010 Share Posted February 22, 2010 You can take an array and implode it into a string i.e <?php $x = array('red','green','blue'); $string = implode(', ',$x); print "My favourite colours are: ".$string; ?> Hope this helps. http://uk3.php.net/implode Link to comment https://forums.phpfreaks.com/topic/192954-getting-array-items-into-one-variable/#findComment-1016184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.