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');