I realize you posted an example, but don't ever use "$this" as a variable name in PHP unless it's referring to an instance of an object within that object. "$this" is reserved in PHP. Even for an example that never runs, it's a very bad idea.
The usual conventions are "$foo", "$bar", and "$baz", but even "$something" is better. I'm not knocking you ro the code, just warning away from bad habits.
I'm not sure I understand what you're trying to do here. The code isn't passing a parameter to example() inside the while loop, so output will always be the same.
"$this" is only compared to one, so it won't run if $this is 4 or 7. Or will it contain another value?
If you need to compare multiple values, I've found the
switch statement works nicely and although somewhat verbose, is clear:
switch ($foo) {
case 1:
case 4:
case 7:
example($foo);
break;
default:
// I always put in a default even if it does nothing.
}
This would also make expanding to checking other values a lot cleaner, or even putting in another set and calling different code.