-
-
Save anonymous/07df1d35405305cb9f69 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
/** | |
* Exercise 1.5 * | |
* Use your array 'countries' and concatinate the first and the last item as a | |
* string. Separate the items with a hyphen (-) and answer with the result. * | |
* Write your code below and put the answer into the variable ANSWER. | |
*/ | |
//Funkar: | |
$lastIndexInCountries = (count($countries)-1); | |
$ANSWER = "$countries[0]" . "-" . "$countries[$lastIndexInCountries]"; | |
//Funkar inte: | |
$ANSWER = "$countries[0]" . "-" . "$countries[(count($countries)-1)]"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment