I want to make an expression in PHP as follows:
if(preg_match("/apples/", $ref1, $matches)) OR if(preg_match("/oranges/", $ref1, $matches)) { Then do something }
Each of them works fine on its own, but I can’t figure out how to do it in such a way that if any of them is right, then perform the function that I have below.
Simple, use the logical OR operator:
if (expression || expression) { code }
For example, in your case:
if( preg_match("/qualifier 1/", $ref1, $matches) || preg_match("/qualifier 2/", $ref1, $matches) ) { do_something(); }
Use |to select one value or another. You can use it several times.
|
preg_match("/(apples|oranges|bananas)/", $ref1, $matches)
EDIT: This post made me hungry.
$matches:
$matches
preg_match('/(apples|oranges)/', $ref1, $matches)
, $matches ( , , ):
preg_match('/(?:apples|oranges)/', $ref1, $matches)
Source: https://habr.com/ru/post/1787492/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1787487/tools-to-visualize-a-database-and-understand-the-datamodel-quickly&usg=ALkJrhgKUEuvXabvy_oOoHZwQFg8kHd7uwВспомогательный запрос SQL для С++ - c++Add UIView to UIViewController - objective-cWhat is the best solution for embedding videos on an ASP.NET site? - asp.netОбеспечение соответствия типа шаблона во время компиляции - c++Заменить бар предварительного натяжения Flex на неопределенный счетчик? - flexLinq handles a variable OrderBy - c #Django, Nginx, a problem with FastCGI caching when changing code - djangoUIWebView on iOS - ioswhat is the easiest way to implement a particle system without openGL or cocos2d - objective-cAll Articles