Source Code:
(back to article)
<?php // Input Array $myArray = [1, 2, 3, 4]; $index = 2; $default = "No Value Found"; $value = isset($myArray[$index]) ? $myArray[$index] : $default; echo "Using Ternary Operator: " . $value . "\n";
Result:
Report an issue