Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

dice assigment

Featured Replies

Hey guys.

 

I´m trying to write down a random number function.

However the number 5 must evulate to "great";

 

I just can't seem to get it to work correctly.

 

 

I want to do (mt_rand(0,6)) and once it hits 5 that it should evaluate to "great".

I can't get it to work even with the use of if and else.

 

Perhaps some'one can plain me a bit more?

Hey guys.

 

I´m trying to write down a random number function.

However the number 5 must evulate to "great";

 

I just can't seem to get it to work correctly.

 

 

I want to do (mt_rand(0,6)) and once it hits 5 that it should evaluate to "great".

I can't get it to work even with the use of if and else.

 

Perhaps some'one can plain me a bit more?

A quick and dirty solution:

 

$number = rand(1,6);
$value = "";

if($number == 1)
  $value = "one";
elseif($number == 2)
  $value = "two";
elseif($number == 3)
  $value = "three";
elseif($number == 4)
  $value = "four";
elseif($number == 5)
  $value = "great";
elseif($number == 6)
  $value = "six";

echo $value;

 

Hope that helped!

Edited by TomCash

  • Author

ah thanks I didn't knew you could target functions in this way, thanks a lot I will remember this one.

+1 for you.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.