Skip to content
View in the app

A better way to browse. Learn more.

MagicDuel Community

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.

Switches

Featured Replies

As i had to find out, you can only do a limited number of things with if-functions, so here is some very basic switch that allows to make basically infinte different events happen in the same item, and with the same activator:

[php]@vc=date('z');
@vd=@vc%7+3; //mod-calculation
//echo @vd; <-- used for test purposes, to see if mod and the cases work right
//echo"<br>";

switch (@vd) { //switch-operator searches for the right case and does the things you told it to do, in this case just echo
case 7: echo "monday";break; // always use 'break;' at the end of the case, else you will get all cases after the right one showing up!!
case 8: echo "tuesday"; break;
case 9: echo "wednesday"; break;
case 3: echo "thursay"; break;
case 4: echo "friday"; break;
case 5: echo "saturday"; break;
case 6: echo "sunday"; break;}[/php]

this one is a pretty simple useage to give out the day of the week, but switches can also easily be combined with keys (strings go in between "", like 'case "first-key":', 'case "second key":' etc.), random event-generators, whatever you want it to do^^

switches also offer a default-option, which is obviously not fitting for my little example code, but if no case mathces, which might happen with keys, you simple add

[php]default: echo "sorry, you don't have the key";[/php]

after the last case (BEFORE '}'!)

Edited by Burns

Nice that it works in MDS in the end as well. You forgot to add the comment about having to reset your "@vd=@vc%7+3" next year with a different number through :P (I told you so :D)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Forum Statistics

  • Total Topics 17.5k
  • Total Posts 182.2k

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.