Well, you said you want to do something based on three conditions and run one process.
So, I gave you an example of that.
If you want to handle all three possibilities just handle separate IF’s without the else. Perhaps you are wanting it this way. If x=p1 do something else if x=p2 do something else do a third thing. This is done something like this:
if (x==p1) {
. . . do process #1
} elseif (x==p2) {
. . . do process #2
} else {
. . . do process #3 if #1 and #2 fail . . .
}
As you see logic is important when you think these processes out. In this example, it handles p1 first, if it succeeds, then the entire process is finished, but, if it is not p1, then it moves on to p2 and if that fails does the final fall-back process… Is that what you need?
Oh, also, in your first post, you had a foreach to loop thru a data array. You wrote it wrong. It would create a variable named “p” but you use x in your tests. So, you really would need to handle it more like this:
foreach($x as $data) {
if($data==p1) {
. . . etc…