330 Locust Dr.
Verona, WI 53593
Powderkeg Web Design
Message Us

5 Built-In PHP Shortcuts to Help Optimize Your Code

February 15, 2013

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!

Technical Account Manager

Matt is a skilled and nimble programmer that assists the entire team wherever help is needed. He has exceptional troubleshooting skills, is an extremely fast coder, and has strong database skills.