3 Years
Discussion Span
Last Post by diafol

a function that outputs all the words ending in a "s", in a sentence sent to it as a parameter.


No... Seriously. Why not try first, then get some feedback?

If you are in a computer science course, I hope you know what a function is. At that, you should know the parameter is what is passed into the function.

You will likely be returning an array of strings which, depending on the language you are using, can be as simple as a regex, quite ironically, as complex as a regex


^^ As he's posting in the PHP forum hopefully its PHP he's using lol ;)


function YourFunctionsName ($string)
    if (substr($string, -1) == ','))
        echo $string;


You can use regex, but it would look like if (preg_match('/,$/', $string)) and this to me is a bit of an overkill


The purpose was to encourage him to try on his own, giving a place to start.

I admit, I answered on my phone and didn't think to look what forum I was in... But answering this kind of question by doing the work for him hardly teaches anything. :/

Also... I do not believe your solution is at all correct to answer his problem. You may want to reread his request.


I am not as polite as you two

Do your own bloody homework
die('lazy students');

Votes + Comments
my sentiments exactly

This is not "SO" nor are contributors here 'rent-a-dupe'. This forum is primarily a learning platform. While we all get carried away from time to time with providing "freebies", this should be avoided where possible as ryantroop correctly points out.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.