shamuraq Posted March 18 Share Posted March 18 how do i convert the following script to adopt ternary operator to shorten it? $radint = mt_rand(1,33); $flip = mt_rand(1,2); if($flip == 2){ $radint *= -1; } Thanx in advance. Quote Link to comment https://forums.phpfreaks.com/topic/319154-using-ternary-operator/ Share on other sites More sharing options...
Solution Barand Posted March 18 Solution Share Posted March 18 $radint = mt_rand(1,33); $flip = mt_rand(1,2); $radint *= ($flip == 2) ? -1 : 1; 1 Quote Link to comment https://forums.phpfreaks.com/topic/319154-using-ternary-operator/#findComment-1618123 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.