10
9
0
Featured in collections
Recommended for you
humanList.teardrop.php
2.5K Views|1 Today
© 2008 - 2019 photofroggy
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.
echo humanList("one");

// 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!

- photofroggy

[EDIT] ~philo23 made the original function!
Image size
217x272px 10.33 KB
Featured in collections
Recommended for you
anonymous's avatar
Join the community to add your comment. Already a deviant? Sign In
Comments (10)
elmfuzz's avatar
elmfuzz| Photographer
wow, that's cool! i like the way it still retains function
Reply  ·  
photofroggy's avatar
photofroggy|Hobbyist Artist
Well, I think it has to, or it wouldn't work.
Reply  ·  
elmfuzz's avatar
elmfuzz| Photographer
ah, but you could also do something like that that's just ASCII art
Reply  ·  
photofroggy's avatar
photofroggy|Hobbyist Artist
Oh right, I see now :slow: Thanks anyway :bucktooth:
Reply  ·  
MrSlowNiko's avatar
MrSlowNiko|Hobbyist General Artist
I knew PHP was a true Art ;)
Reply  ·  
photofroggy's avatar
photofroggy|Hobbyist Artist
:bow:
Reply  ·  
MrSlowNiko's avatar
MrSlowNiko|Hobbyist General Artist
:)
Reply  ·  
whitepowa's avatar
goddamn!! lol, it truly is an art.
Reply  ·  
photofroggy's avatar
photofroggy|Hobbyist Artist
Thanks :)
Reply  ·  
anonymous's avatar
Join the community to add your comment. Already a deviant? Sign In
© 2019 DeviantArt
All Rights reserved