Switch function - Tank Alias - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Switch function - Tank Alias.php
- <?php
- function tankAlias(&$tank) {
- switch ($tank["country"]) {
- case "Russia":
- $tank["alias"] = "Soviet";
- break;
- case "Germany":
- $tank["alias"] = "German";
- break;
- case "USA":
- $tank["alias"] = "American";
- break;
- default:
- $tank["alias"] = NULL;
- }
- }
- $tank1 = ['name'=>'T-34', 'country'=>'Russia'];
- $tank2 = ['name'=> 'Tiger', 'country'=>'Germany'];
- $tank3 = ['name'=> 'Churchill', 'country'=>'UK'];
- tankAlias($tank1);
- print_r($tank1);
- echo "\n";
- tankAlias($tank3);
- print_r($tank3);
File Description
- Switch function - Tank Alias
- PHP Code
- 23 May-2020
- 603 Bytes
You can Share it:
Latest PHP Pastes