Skip to content

Instantly share code, notes, and snippets.

/arrayindex.php Secret

Created February 3, 2016 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/07df1d35405305cb9f69 to your computer and use it in GitHub Desktop.
Save anonymous/07df1d35405305cb9f69 to your computer and use it in GitHub Desktop.
/**
* 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