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:

#Create the variable
$toggle=true;
#Switch it
$toggle=(!$toggle);

Simple!

Related posts:

  1. Install a Ranger Package Without Ranger Following on from my remove ranger script, here is a...

Related posts brought to you by Yet Another Related Posts Plugin.

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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>