Check if String has only Integers separated by comma in PHP

后端 未结 3 989
眼角桃花
眼角桃花 2021-01-12 19:10

I am really empty at Regex side and that\'s why couldn\'t get how to make a Regex in PHP which checks if the string has this particular sequence of characters.



        
3条回答
  •  隐瞒了意图╮
    2021-01-12 19:32

    Just for fun with no regex:

    var_dump(
        !array_diff($a = explode(',', $str), array_map('intval', $a))
    );
    

提交回复
热议问题