I'm not sure that will work if "1" is the ONLY value in the column (there's no comma to match).
Probably an easier pattern, but:$var = preg_replace('/,1\b|\b1,/', '', $var);
If I were stuck with this data, I would either use the explode/implode sequence:
$list = '1,3,5,2,8,10'; $list = explode(',', $list); if (($sub = array_search(1, $list)) !== false) unset($list[$sub]); $list = implode(',', $list);OR add a comma to the beginning and the end of the string and then replace ",1," with ",", and then trim the leading/trailing commas:
$list = '1,3,5,2,8,10'; $newlist = ',' . $list . ','; $newlist = str_replace(',1,', ',', $newlist); $newlist = trim($newlist, ',');Go to the full post