Re: Making a string from an Array

From: Date: Thu, 25 Oct 2001 16:38:42 +0000
Subject: Re: Making a string from an Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72300@lists.php.net to get a copy of this message
A small addition: the code below would make a string, but it would be a single word (no spaces or other word boundaries). Use this instead: $ignored .= " " . $words[$i]; That inserts a space before each additional word. Unfortunately it also adds a space at the beginning but you can get rid of that after the processing is done. Mike "Stewart Taylor" <Stewart.Taylor@uk.thalesgroup.com> wrote in message news:2B25A9C95DC8D411BBE500508BB19239515E31@ntslxch1.int.rdel.co.uk... > $ignored = ""; > $include = ""; > > <snip> > { > $ignored.= $words[$i]; > } > else > { > $included.= $words[$i]; > > -Stewart > -----Original Message----- > From: Sam [mailto:Sam@dragoman.co.uk] > Sent: 25 October 2001 16:18 > To: 'php' > Subject: [PHP] Making a string from an Array > > > Hi all, > this may be an easy question, but I'm stuck... > > how can this, > > $words = explode(" ", $keywordText); > > for ( $i = 0; $i < count( $words ); $i++ ) > { > if ($words[$i]=="on" OR $words[$i]=="the" OR $words[$i]=="in" > OR$words[$i]=="at" OR $words[$i]=="is" OR $words[$i]=="it") > { > $ignored[] = $words[$i]; > } > else > { > $included[] = $words[$i]; > } > } > > How can I make $included and $ignored a string instead of an array. > > Thanks > Sam Rose > > p.s. Also I'm only on the digest, so if you could reply directly to me as > well, that would be a bonus.

« previous php.general (#72300) next »