Joined January 2013
·
Posted to
Always Return An Even Number
over 1 year
ago
I had to remove the count() before it worked. Also why don't you do a bitwise check, if the first bit is 1, we know it's an odd number:
// Add or substract 1 if it's odd
echo $num & 1 ? $num + 1 : $num;
For more information about bitwise operators check:
http://php.net/manual/en/language.operators.bitwise.php
Also note that the rounding seems a bit unpredictable, both 12345 and 12343 returned 12344 in your case.
Posted to
Check a 1D array for emptiness
over 1 year
ago
if (! array_filter($values, 'strlen'))
I think this line is more verbose, but I got to admit that it's a bit slower than @kanuj 's. Just a matter of preference I guess.
Achievements
88 Karma
0 Total ProTip Views

Python
Would you expect anything less? Have at least one original repo where Python is the dominant language

Komodo Dragon
Have at least one original repo where Java is the dominant language

Nephila Komaci 3
Have at least three original repos where PHP is the dominant language

Mongoose 3
Have at least three original repos where Ruby is the dominant language

Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos

Mongoose
Have at least one original repo where Ruby is the dominant language

Charity
Fork and commit to someone's open source project in need

Nephila Komaci
Have at least one original repos where PHP is the dominant language

Forked
Have a project valued enough to be forked by someone else
Great tip!
Remember that you can always change the symlink to
if you like the full name over the abbreviation (as I do).