The preg_match function. Working with several variables at once.

I’ve been using this code for a while now:

if (preg_match("/^/", $peremennaya)) {

It checks for the presence of “word” at the beginning of the $peremennayavariable. But how to do a simultaneous bulk check? That is, let’s say I need to simultaneously check for the presence of the word “search” in the variable $get, as well as the word “forward” in the variable $santexand the word “price” in the variable $korzina.

I think you need to work with “{” brackets here. But I would like to hear the opinion of knowledgeable people…

Answer 1, authority 100%

Multiple preg_matchin one condition

if (
    preg_match("/^/", $get) &&
    preg_match("/^/", $santex) &&
    preg_match("/^/", $korzina)
) {
    // - ...

Answer 2, authority 33%

1) Your check is not “presence”, but “started from”
2) As far as I know – what you want, as you suggest – I really do not advise, but you can do this:

  join('\v', array( $var1, $var2, $var3) )

\v– vertical tab