Take the 2-minute tour ×

I have an array which is a list of domains, I want to print all of the items in the array except the one which contains $x. $x is variable so basically it never prints the array item when it contains $x. Can anyone help me? :)

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Darkey's answer is correct assuming you don't want to print array values that equal $x - but if you don't wish to print those that "contain" $x, try:

    if (strpos($value, $x) === false) {

If $x = stack, then entries such as "stackoverflow.com" and "getstacked.org" would be excluded

share|improve this answer
Thank you this was exactly what I was looking for. –  zuk1 Oct 17 '08 at 9:27
add comment

Your Answer


