Equivalent of . test() (js) in php

Asked

Viewed 45 times

1

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

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

php has some similar function?

1 answer

4


Yes. No PHP you can use the preg_match

if ( preg_match("/[\d]+/", $value) ) {
   /* Code Here */
}
  • Thank you very much. That’s right. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.