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

Advanced Conditionals for comparison

Development and Programming

DocDiversity's avatar
DocDiversity
14 posts
14 years ago
DocDiversity's avatar DocDiversity

Does anybody know an addon or a solution to do something like this:

{if variable_a within variable_b}Do Stuff{/if}

With “within” I mean variable_a is contained in variable_b. Like here:

variable_a = “lam” variable_b = “slamming”

or

variable_a = “34” variable_b = “5&39;&34;$7&23;&66;”

Note: I have absolutely no clue of PHP :-(

I’d appreciate your help very much 😊

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen

Hi DocDiversity,

My PHP isn’t fantastic but I believe this should get you what you need here using PHP :

<?php

 $variable_a = "5&39;&34;$7&23;&66;";
 $variable_b = "34";

 if(stristr($variable_a, $variable_b) === FALSE) {
  echo 'NOT FOUND!!';
 } else {
  echo "FOUND!!";
 }

?>

There may well be a better way of doing this though and hopefully if there is someone will pipe up and let us both know 😉

Hope that helps a bit though.

Best wishes,

Mark

       
DocDiversity's avatar
DocDiversity
14 posts
14 years ago
DocDiversity's avatar DocDiversity

Hi Marc,

that helps. Very! Thanks a lot!

Cheers

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen

Hi DocDiversity,

No problems. Hope everything else goes well for you.

Best wishes,

Mark

       

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.