Created
November 18, 2009 02:06
-
-
Save erikreagan/237491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The function strlen() returns the interger value of the string length within the parentheses | |
// We can string multiple together with math operators for equations | |
// PHP enabled in template | |
// Parsing Stage: Output | |
// Simple conditional here | |
// We group the strlen values in parentheses to get their value | |
// and compare to the following integer (10 in the example) | |
// Basic example | |
if ((strlen("{custom_field_1}") + strlen("{custom_field_2}")) > 10) | |
{ | |
// whatever your code requires | |
} | |
// Alternate syntax | |
if ((strlen("{custom_field_1}") + strlen("{custom_field_2}")) > 10) : | |
// whatever your code requires | |
endif; | |
?> | |
<p>Here's how I would use it in a template:</p> | |
<?php if ((strlen("{custom_field_1}") + strlen("{custom_field_2}")) > 100) : ?> | |
This shows up because the combined length of {custom_field_1} and {custom_field_2} is greater than 100. | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment