1 2 3 4 5 6 7 8 9 10 11 12 13
<?php function removeFromString($str, $item) { $parts = explode(',', $str); while(($i = array_search($item, $parts)) !== false) { unset($parts[$i]); } return implode(',', $parts); } echo removeFromString('one,two,three,four', 'two'); ?>
1
one,three,four