Ricky55 Posted April 12, 2011 Share Posted April 12, 2011 Hi I have two quite lengthly arrays made up of strings but quite a few bits of each array are repeated. I'm using one of the arrays to control the downstate of my navigation and the other to conditionally load a CSS file. Is there are way in a if statement to say if array 1 or array 2 then do something? I am currently checking one array by using this code <?php if (in_array($title, $rangePages)) { ?> <link rel="stylesheet" href="/css/range-viewer.css" media="screen"> <?php } ?> By the way my other array is called $forProdDownState Quote Link to comment https://forums.phpfreaks.com/topic/233481-check-if-in-two-arrays/ Share on other sites More sharing options...
Ricky55 Posted April 12, 2011 Author Share Posted April 12, 2011 Sorry I meant to say is there any way to say if in array 1 or in array2 then do something. Quote Link to comment https://forums.phpfreaks.com/topic/233481-check-if-in-two-arrays/#findComment-1200546 Share on other sites More sharing options...
dcro2 Posted April 12, 2011 Share Posted April 12, 2011 Like this? if (in_array($title, $rangePages) || in_array($title, $forProdDownState)) { Quote Link to comment https://forums.phpfreaks.com/topic/233481-check-if-in-two-arrays/#findComment-1200548 Share on other sites More sharing options...
Ricky55 Posted April 12, 2011 Author Share Posted April 12, 2011 Yeah that's exactly what I wanted. I was just writing the code wrong. Still learning. Thanks very much! Quote Link to comment https://forums.phpfreaks.com/topic/233481-check-if-in-two-arrays/#findComment-1200569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.