Making a (page =) equal more than one page ?

Started by MoreBloodWine, June 12, 2015, 04:29:22 AM

Previous topic - Next topic

MoreBloodWine

Question...


              <li <?php if ($page == 'lotteries' || $page == '*_lottery') { echo 'class="active"'; } ?>>
                <a href="index.php?page=lotteries"><?php echo $lotto_button?></a>
              </li>


I know the above will never work but it helps me get my question asked, how can I have it so the * is wildcard for any possible combination ?

ex. hi_lottery, how_lottery, are_lottery, you_lottery

Basically as I add pages that are *_lottery, the class should always be active.

Ty.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


MoreBloodWine

preg_match seems to be what I want but the stuff I'm trying to follow online I keep messing up, that being said. If someone could help me out and finish it off I'd really appreciate it, Ty.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


MoreBloodWine

Solved.


              <li <?php if ($page == 'lotteries' || preg_match("/(.*)_lottery/"$page)) { echo 'class="active"'; } ?>>
                <a href="index.php?page=lotteries"><?php echo $lotto_button?></a>
              </li>
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


Advertisement: