dmirsch Posted October 5, 2011 Share Posted October 5, 2011 This may be super simple, but it's stumping me. Is this an If/Then clause: ($month != 1 ? $month - 1 : 12) Is it saying if $month does not equal 1 then $month-1; if so, then what does the colon mean? If not, then what is this piece of code doing? Quote Link to comment Share on other sites More sharing options...
Ayon Posted October 5, 2011 Share Posted October 5, 2011 Yes that's correct except the paranteces should not wrap it all. It should be either ($month != 1) ? $month - 1 : 12; or $month != 1 ? $month -1 : 12; Quote Link to comment Share on other sites More sharing options...
djlee Posted October 5, 2011 Share Posted October 5, 2011 basically yes, its actually called a "ternary statement" $month = ($month == 1 ? 'Jan': ($month == 2 ? 'Feb' : ($menth == 3 ? 'Mar' : ($month == 4 ? 'Apr' : ( $month > 4 ? 'I got bored here' : 'Thats not right!' ))))); Quote Link to comment Share on other sites More sharing options...
dmirsch Posted October 5, 2011 Author Share Posted October 5, 2011 so the colon must be the "else" portion then. thanks everyone! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.