Re: array intersection problem
| From: | Richard Lynch | Date: | Wed, 15 Aug 2001 04:46:31 +0000 |
| Subject: | Re: array intersection problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62762@lists.php.net to get a copy of this message | ||
> $invalid = array("1","3","9");
> $questions =
> array("1","2","3","4","5","6","7","8","9");
>
> $new_questions = array("<font color=red>1</font>",
> "2",
> "<font color=red>3</font>",
> "4","5","6","7","8",
> "<font color=red>4</font>");
There's no one-line built-in array_xxx function to do that, AFAIK. This
isn't Lisp, after all :-)
reset($questions);
while (list($index, $qid) = each($questions)){
if (in_array($qid, $invalid)){
$new_questions[$index] = "<font color=red>$qid</font>";
}
else{
$new_questions[$index] = $qid;
}
}
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm