Check if variable has a number php

后端 未结 5 1609
感动是毒
感动是毒 2021-01-30 15:09

I want to check if a variable has a number in it, I just want to see if there is one I don\'t care if it has any thing else in it like so:

\"abc\" - false
\"!./#         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 15:35

    you can use this pattern to test your string using regular expressions:

    $isNumeric = preg_match("/\S*\d+\S*/", $string) ? true : false;
    

提交回复
热议问题