In PHP you can do
//Check if $arr["a"] exists, and assign if it does, or assign $arr["b"] else
$arr = array("a" => "123", "b" => "456");
$test = isset($arr["a"]) ? $arr["a"] : $arr["b"];
But in PHP 7 you can do
$arr = array("a" => "123", "b" => "456");
$test = $arr["a"] ?? $arr["b"];
See operators
Note that $arr["a"] || $arr["b"]in PHP it only calculates a boolean value.
source
share