Is there a shorter way of writing this (without using regex or string-matching functions)?
if($page=='page1.php' || $page=='page2.php' || $page=='page3.php' || $page=='page4.php'){ do something...}
I'm looking for something like:
if($page==('page1.php', 'page2.php', 'page3.php', 'page4.php')){do something...}
but I know that isn't correct. Any suggestions?
Try in_array
:
if (in_array($page, array('page1.php', 'page2.php', 'page3.php'))) { ... }
http://php.net/manual/en/function.in-array.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With