Introducing function humanList();
When looking through a pastebin for a particular channel on dAmn, I found this function made by someone else, and you can see it here
. Now when I saw this function I didn't know what it was doing until I looked at the intended outputs, and upon discovering its purpose, I knew that it could be simplified. I took it upon myself to create a revision of the function. This revision can be found here
So I have a revision which works, but I haven't yet explained what it does yet. The function takes an array of items and returns these items as a string, which is near enough grammatically correct. Examples below.
// This would just return the string itself.
// Here we would get "one and two" in return for our efforts.
echo humanList(array("one", "two"));
// If we get slightly more complicated, we get "one, two and three"
echo humanList(array("one", "two", "three"));
// And for an even more complicated one, we get "one, two, three and four".
echo humanList(array("one", "two", "three", "four"));
Hopefully you can see why this function would be useful. You could call it a "list pretty-printer", but I'm not sure if that's the correct term for it.
So, I eventually get bored, and decide to toy with the layout of the function, and this picture is the result. It contains exactly the same code and it does exactly the same thing, so there's nothing to be worried about. I tried making it look like a teardrop because I've never done anything like this before and I thought it would be easy, but I still had some trouble with positioning certain things.
Thanks for reading, critique is appreciated!
made the original function!