dongyigua4468 2016-02-19 10:16
浏览 1331
已采纳

如何使用PHP检查一个字符串是否有逗号分隔值

I need one help.I need to check two type of string value using PHP. I am explaining one example below.

suppose one variable

$sup_id='4' //(datatype-varchar)

$sup_id='4,5,6' //(datatype-varchar)

in above example i have different value in same variable name.Here how can i check that the same variable has one value or different with comma(,) separated.Please help me.

  • 写回答

2条回答 默认 最新

  • dpxpz37157 2016-02-19 10:35
    关注

    Can be easily done by strpos

    if (strpos($sup_id, ',') !== false) {
      echo "There's a comma in the string...!!!";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?