We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

$end_char

Development and Programming

thefifthlion's avatar
thefifthlion
133 posts
14 years ago
thefifthlion's avatar thefifthlion

Let me start off by saying I’m a designer/front-end developer. I just need to a little php help.

I’m writing a conditional where I need to obtain the character count of a field. I’ve enabled PHP for the template and I have the following code but I’m just guessing so it’s not working, do I need to use eval?

Any advice would be appreciated.

{if <?php requirements($end_char)?> >= 10}

[Mod Edit: Moved to the Development and Programming forum]

       
thefifthlion's avatar
thefifthlion
133 posts
14 years ago
thefifthlion's avatar thefifthlion

it won’t evaluate the field

{if <?php echo strlen("{fieldentry}”); ?> >= 10}

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Make sure PHP mode is set to Output on the template settings.

If you’re using PHP on Output you may need to keep the conditional in PHP as well (untested so I’m unsure).

<?php

if (strlen("{field_name}") >= 10)
{

?>
// something here if true
<?php

}

?>

Or the alternate control structure:

<?php if (strlen("{field_name}") >= 10) : ?>
// something here if true
<?php endif; ?>
       
thefifthlion's avatar
thefifthlion
133 posts
14 years ago
thefifthlion's avatar thefifthlion

Thanks Erik,

That did the trick. I really appreciate you taking the time to answer my question.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.