php nested ternary operator

Solutions on MaxInterview for php nested ternary operator by the best coders in the world

showing results for - "php nested ternary operator"
Ian
14 Nov 2020
1// The below statement is an exaple of the nested ternary operator in PHP
2echo ($row["position"] != "NA") ? $row["position"] : 
3(($row["current_degree"] != "NA") ? $row["current_degree"] : 
4 $row["qualification"]);
5
6// The equivalent if else structure is given below
7
8if ($row["position"] != "NA"){
9  echo $row["position"];
10} elseif($row["current_degree"] != "NA"){
11  echo $row["current_degree"];
12} else{
13  echo $row["qualification"];
14}