Re: Making a string from an Array

From: Date: Thu, 25 Oct 2001 19:45:23 +0000
Subject: Re: Making a string from an Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72334@lists.php.net to get a copy of this message
try this out $words = explode(" ", $keywordText); $compare = array('on', 'the', 'in', 'at', 'is', 'it'); foreach ($words AS $value) { if (in_array($value, $compare)) { $ignored[] = $value; } else { $included[] = $value; } } Jim Lucas ----- Original Message ----- From: "Sam" <Sam@dragoman.co.uk> To: "'php'" <php-general@lists.php.net> Sent: Thursday, October 25, 2001 8:17 AM 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 (#72334) next »