I am new to PHP and trying to learn things.
Is it posible to avoid the use of temporary variables ?
<?php
function get_name()
{
// assume that this function return 3
// values on different conditions "name0" "name1" or "name2";
}
$result = ( get_name() == "name0" || get_name() == "name1") ? "Primary" : "Secondary" ;
echo $result;
?>
on the above i am calling the get_name() function two times , which means two calls on the same function.
Is it possible to achieve the same with just one call without saving it into a temporary variable?
What is the commonly used practices ?
Update : I edited the question to be more specific.Almost all answers are satisfactory,Hope that this update will help for new readers.
I would do that:
Documentation: in_array