Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.