I'm working on custom breadcrumbs in drupal website and have to display one word based on a few categories PHP instruction like: <?php if (($ppp=='bracelets') || ($ppp=='earrings') || ($ppp=='brooches') || ($ppp=='necklaces')): print_r('JEWERLY'); elseif (($ppp=='combs') OR ($ppp=='feathers') OR ($ppp=='hairpins') OR ($ppp=='squiggles') OR ($ppp=='tiaras')): print_r('HEADPIECES'); else: print_r('OTHER'); endif; ?> always gives me result 'OTHER' For exaple I put before <?php print_r($ppp);?> and get Bracelets OTHER or Feathers OTHER What do I do wrong? Thanks
Bracelets (capital B) does not equal bracelets(small b), use the strtolower function instead. You could just add the line $ppp=strtolower($ppp) PHP: before this script. Also, it may be easier to use the in array function when comparing a string to a lot of other strings: if(in_array($ppp,array('brachelets','earrings','brooches','necklaces'))): print_r('JEWERLY'); elseif(in_array($ppp,array('combs','feathers','hairpins','squiggles','tiaras'))): print_r('HEADPIECES'); else: print_r('OTHER'); endif; PHP: in_array is case insensitive, therefor you don't need to lowercase the needle.