r($condition, $a, $b = null)

Returns either $a or $b by the given condition

  • $condition (mixed)
  • $a (mixed)
    Returned if $condition is true
  • $b (mixed)
    Returned if $condition is false
  • return (mixed)

Example

With two options

r(1 == 2, 'hell freezes over', 'everything is ok');
// will most definitely return 'everything is ok'

With a single option

r(1 == 2, 'hell freezes over');
// will return null