how to use preg_match to check whole text

前端 未结 2 1073
执笔经年
执笔经年 2021-01-17 03:12

Hi i have a problem with preg_match function.
i want to check whole text against pattern and return true if whole text matched with pattern and false for not matched or

2条回答
  •  清歌不尽
    2021-01-17 04:11

    You need to use ^ to indicate the start of the string and $ for the end

    if (preg_match("/^[\d]+$/","99ab")) return true; 
    else return false;
    

提交回复
热议问题