Check if variable has a number php

后端 未结 5 1611
感动是毒
感动是毒 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:19

    This should help you:

    $numberOfNumbersFound = preg_match("/[0-9]+/", $yourString);
    

    You could get more out of the preg_match function, so have a look at its manual

提交回复
热议问题