dinoslikeroar Posted September 27, 2018 Share Posted September 27, 2018 I need to convert variable being matched to uppercase and preg_match for the value in the case statement. I'm not sure what exactly I am missing. { $x = ucfirst($value); switch ($x) { case 'Urine'; if(preg_match('/(urine)(URINE)(Urine)/', $x)) { return 'UR'; } } } Quote Link to comment https://forums.phpfreaks.com/topic/307731-preg_match-in-statement/ Share on other sites More sharing options...
cyberRobot Posted September 27, 2018 Share Posted September 27, 2018 You could use a case-insensitive match. The first example in the PHP manual shows you how.http://php.net/manual/en/function.preg-match.php Note: with a case-insensitive match, you can remove the switch statement and the call to ucfirst(). Quote Link to comment https://forums.phpfreaks.com/topic/307731-preg_match-in-statement/#findComment-1561161 Share on other sites More sharing options...
benanamen Posted September 27, 2018 Share Posted September 27, 2018 OP, tell us what the real problem you are trying to solve is instead of your attempt at solving it. Quote Link to comment https://forums.phpfreaks.com/topic/307731-preg_match-in-statement/#findComment-1561172 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.