Find numeric value in csv

后端 未结 2 347
耶瑟儿~
耶瑟儿~ 2021-01-27 11:54

I need to check if a particular numeric id is in a given string or comma separated values.

$myVal = 20;

String could contain just a single valu

2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-27 12:19

    You could use explode to split the string into an array. Something like:

    $parts = explode(',', $str);
    

    Then you could use in_array on that.

    If you're reading a file, take a look at fgetcsv or str_getcsv.

提交回复
热议问题