IF statement not case sensitive

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 3, 2008   (RSS)

Re: [rjbathgate] IF statement not case sensitive

By Dave - November 3, 2008

Hi Rob,

Try lowercasing both values before you compare them with strtolower. Docs: http://php.net/strtolower

<?php $iscorrect = ( strtolower($propertiesRecord['answer']) == strtolower($FORM['answer']) ); ?>

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] IF statement not case sensitive

Thanks Dave, worked fine...

Just as you posted that, I had also come up with this, which also worked, but was a bit more long winded (so sticking with yours!)

<?php $compare = strcasecmp(($propertiesRecord['answer']),($FORM['answer'])); ?>
<?php if ($compare == '0'): ?>
<h2>RIGHT</h2>
<?php else: ?>
<h2>WRONG</h2>
<?php endif; ?>


Cheers