-
-
Save tiffany-taylor/0a3c8fe9ed5db0a3bb93a06d39895fe9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function do_a_thing(string $firstVar, string $secondVar){} | |
$items = [ | |
'mouse' => 'some arbitrary value', | |
'keyboard' => 'some arbitrary value', | |
'monitor' => 'some arbitrary value', | |
'microphone' => 'some arbitrary value', | |
'headset' => 'some arbitrary value', | |
'PC' => 'some arbitrary value', | |
'webcam' => 'some arbitrary value', | |
'desk' => 'some arbitrary value', | |
'pen' => 'some arbitrary value', | |
'post-it' => 'some arbitrary value', | |
]; | |
$limitValues = ['mouse', 'keyboard', 'monitor', 'microphone', 'headset']; | |
foreach ($items as $key => $value) { | |
if (array_keys($limitValues, $key)) { | |
do_a_thing($key, $value); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function do_a_thing(string $firstVar, string $secondVar){} | |
$items = [ | |
'mouse' => 'some arbitrary value', | |
'keyboard' => 'some arbitrary value', | |
'monitor' => 'some arbitrary value', | |
'microphone' => 'some arbitrary value', | |
'headset' => 'some arbitrary value', | |
'PC' => 'some arbitrary value', | |
'webcam' => 'some arbitrary value', | |
'desk' => 'some arbitrary value', | |
'pen' => 'some arbitrary value', | |
'post-it' => 'some arbitrary value', | |
]; | |
foreach ($items as $key => $value) { | |
switch ($key) { | |
case 'mouse': | |
case 'keyboard': | |
case 'monitor': | |
case 'microphone': | |
case 'headset': | |
do_a_thing($key, $value); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment