If it's something constant in the project, I'd recommend creating a function for it. Including, it would be possible, in addition to the suggestions in the other answers, use the function array_reduce
:
function has_same_value($array, $value) {
return array_reduce($array, function ($carry, $item) use ($value) {
return $carry && ($item == $value);
}, true);
}
So, just do:
return has_same_value([$title, $squad, $level], 0);
See working at Repl.it | Ideone
Or:
function array_all($array, $callback) {
foreach($array as $item) {
if (!$callback($item)) {
return false;
}
}
return true;
}
Which benefits from the short circuit of logical expressions, stopping to iterate in the first false item.
$title = 0;
$squad = 0;
$level = 0;
$resultado = array_all([$title, $squad, $level], function ($item) {
return $item == 0;
});
var_dump($resultado); // bool(true)
See the Repl.it | Ideone