.test () (js) equivalent in php

1

In JavaScript, we have the function test() , for example:

/Test \[(\d+)\]/gi.test(string); // Pode retornar true ou false.

Does php have a similar function?

    
asked by anonymous 31.12.2017 / 21:52

1 answer

4

Yes. In PHP you can use preg_match

if ( preg_match("/[\d]+/", $value) ) {
   /* Code Here */
}
    
31.12.2017 / 21:53