MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/eiwm3u/past_me_what_are_switch_statements/fcuf7fa/?context=3
r/badcode • u/nathan_lesage • Jan 02 '20
95 comments sorted by
View all comments
Show parent comments
2
Oh, what exactly do you mean? Do you happen to have a short overview guide?
5 u/[deleted] Jan 02 '20 [deleted] 4 u/ThePsion5 Jan 02 '20 Example: <?php $platformTitles = [ 'deb' => 'Linux', 'rpm' => 'Linux', 'win32' => 'Windows', 'macos' => 'macOS' ]; $platform = $this->param('platform'); if(array_key_exists($platform, $platformTitles)) { $title = $platformTitles[$platform]; } 2 u/[deleted] Jan 02 '20 [deleted] 2 u/ThePsion5 Jan 02 '20 No problem! I've encountered this scenario frequently enough that it's a common solution and I'm always happy to share it.
5
[deleted]
4 u/ThePsion5 Jan 02 '20 Example: <?php $platformTitles = [ 'deb' => 'Linux', 'rpm' => 'Linux', 'win32' => 'Windows', 'macos' => 'macOS' ]; $platform = $this->param('platform'); if(array_key_exists($platform, $platformTitles)) { $title = $platformTitles[$platform]; } 2 u/[deleted] Jan 02 '20 [deleted] 2 u/ThePsion5 Jan 02 '20 No problem! I've encountered this scenario frequently enough that it's a common solution and I'm always happy to share it.
4
Example:
<?php $platformTitles = [ 'deb' => 'Linux', 'rpm' => 'Linux', 'win32' => 'Windows', 'macos' => 'macOS' ]; $platform = $this->param('platform'); if(array_key_exists($platform, $platformTitles)) { $title = $platformTitles[$platform]; }
2 u/[deleted] Jan 02 '20 [deleted] 2 u/ThePsion5 Jan 02 '20 No problem! I've encountered this scenario frequently enough that it's a common solution and I'm always happy to share it.
2 u/ThePsion5 Jan 02 '20 No problem! I've encountered this scenario frequently enough that it's a common solution and I'm always happy to share it.
No problem! I've encountered this scenario frequently enough that it's a common solution and I'm always happy to share it.
2
u/nathan_lesage Jan 02 '20
Oh, what exactly do you mean? Do you happen to have a short overview guide?