You are here: Re: joining variables together « PHP Programming Language « IT news, forums, messages
Re: joining variables together

Posted by David Haynes on 05/29/06 19:03

Ian Davies wrote:
> Thanks Aho
>
> sorry I should have added, what if I want each newly added item to the
> session to display as seperat lines when returned to a text field?
>
> Ian

$lines = $_SESSION['line1'].'<br>'.$_SESSION['line2'];
or
$lines = sprintf("%s<br>%s", $_SESSION['line1'], $_SESSION['line2']);
or
$prefix = 'line';
$lines = '';
foreach($_SESSION as $key => $value) {
if( substr($key, 0, strlen($prefix)) == $prefix) {
if( $lines == '' ) $lines = $value;
else $lines = sprintf("%s<br>%s", $lines, $value);
}
}

This assumes that all the lines you want to join together begin with the
tag name 'line'. (e.g. line1, line2, line_foo, etc.)

-david-

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация