You are here: Re: hm? array and string? « PHP Language « IT news, forums, messages
Re: hm? array and string?

Posted by Kimmo Laine on 06/28/05 08:49

"roN @ work" <nospam@hotmail.com> wrote in message
news:3ic4teFkp3ouU1@individual.net...
> Hi,
>
> why is OutStr=0 after executing below code?
> I just want to add all the Items in the Array into a String....the String
> should look like this after:
> [String]
> <option>ElementA</option>
> <option>ElementB</option>
> <option>ElementC</option>
> [/String]
>
> [Code]
> $count=count($spamArray);
> $outStr="";
> for($j=0; $j<$count; $j++ )
> {
> $outStr+="<option>".$spamArray[$j]."</option>\n";
> }
> [/Code]
> why is $OutStr=0?
> Thank you!


It's 0, because you are summing strings (which are evaluated 0, since they
are non-numeric) instead of concatenating. Use the concatenation operator .
instead.
Like this:
$outStr.="<option>".$spamArray[$j]."</option>\n";

Thinking or reading the manual helps also.

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com

 

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

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