Everyone wants to make the neatest code possible, but sometimes things can get out of control and you end up with an illegible mess. Here are a few tricks I use to clean up my code.

1. Ternary If Statements – I use this the most, I would say I use it at least once for any script I write. Very useful for adding classes to multiple elements and specifying the last element in the bunch. Or alternating between even and odd rows.

2. in_array() Function – Instead of comparing the same variable multiple times, use the in_array() function to shorten up the if statement

3. range() Function

4. list() Function

5. switch() Statement – Common statement that I’m sure most of us are aware of, but still useful to clean up code.

Do you use any of these functions? Have any of your own? Share it!