Jump to content

flatronn

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by flatronn

  1. Then why dont you bugger off and stop wasting my time
  2. Hi , I have got here so far as below <?php $people = array("Peter", "Joe", "Glenn", "Cleveland"); reset($people); while (list($key, $val) = each($people)) { echo "$key => $val<br />"; } ?> My problem how to get a comma between each person and then a and at the last name So the string would look like: (peter,Joe,Glenn and Cleveland.) CODING FOR THAT SEEMS VERY DIFFICULT. Cheers
  3. Hi, I have been given a excercise to do but am strugling with it the question is below if some one could enlighten me on how it could be done. Write a function to return a list of people This function should accept an array of people's names as an argument and return a string list of these names. If there is a single person, the name should be returned as is. If there are two people, the two names should be separated by the word ‘and’. If there are more than two people, the last two names should be separated with the word ‘and’, and all previous names separated with a comma. Test the function with the following arrays: $test1 = array('Person One'); $test2 = array('Person One', 'Person Two'); $test3 = array('Person 1', 'Person 2', 'Person 3'); $test4 = array('Person 1', 'Person 2', 'Person 3', 'Person 4' 'Person 5', 'Person 6');
×
×
  • Create New...