PHP Toggle Variable

A neat trick I use in PHP is a toggle variable, usually when I’m creating tables and want to alternate the styles.

To use a toggle variable:

<code>#Create the variable
$toggle=true;
#Switch it
$toggle=(!$toggle);</code>

Simple!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.