The question is not very clear, I would recommend that for a future occasion at least put some pseudo-code, if I translate literally what you are asking would be something like this:
<?php
function sayHelloWord($number) {
echo "Hello Word ($number) \n";
}
# Genera un número entre 0 y 5
$b = rand(0, 5);
if ($b == 1) {
sayHelloWord($b);
} elseif ($b == 2) {
sayHelloWord($b);
} else {
echo "El numero es: " . $b ."\n";
}
The way I think the majority would think it would be:
<?
...
$values = [1,2];
if (in_array($b, $values)) {
sayHelloWord($b);
} else {
echo "El numero es: " . $b ."\n";
}
...
If the answer is not here, then it would be "healthy" to publish what you have done and ask for help specifically in the segment of the code that does not see well.