mercredi 30 décembre 2015

storing something if the statement is ture

This is a simple code I can't figure out

if(preg_match(  "/where/","where's my backpack") == true){
      echo "this is a match";
                        // this is the part i cant figure out
                    // how can I store it as == $match1
                    // I tried $match1 == "this is a match"; but it didn't work   

                }else{
                //$match1= " "; << this what I tried and didn't work
       //when I say echo match1 later, it displays this is a match even when its wrong
        }

how can I store it as a variable or something for later. for example, if those two matches are true, store it as $match1 so that I can later say 'echo $match1' so that it displays "this is a match". if not just display a space.

the overall code is in php BTW

Aucun commentaire:

Enregistrer un commentaire