For that you need to use a case insensitive regex i
flag.
<?php
$string = "orders,items,friends,students OrdeRs or orders OR stuDents or FrIends or students";
preg_match_all('/(orders|items|friends|students)/i', $string, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[1]); $i++) {
echo $result[1][$i]."\n";
}
/*
orders
items
friends
students
OrdeRs
orders
stuDents
FrIends
students
*/
?>
DEMO
Regex Explanation:
(orders|items|friends|students)
Options: Case insensitive;
Match the regex below and capture its match into backreference number 1 «(orders|items|friends|students)»
Match this alternative (attempting the next alternative only if this one fails) «orders»
Match the character string “orders” literally (case insensitive) «orders»
Or match this alternative (attempting the next alternative only if this one fails) «items»
Match the character string “items” literally (case insensitive) «items»
Or match this alternative (attempting the next alternative only if this one fails) «friends»
Match the character string “friends” literally (case insensitive) «friends»
Or match this alternative (the entire group fails if this one fails to match) «students»
Match the character string “students” literally (case insensitive) «students»