PHP remove number from comma seperated string stored in db [duplicate]
问题 This question already has answers here : Fastest way of deleting a value in a comma separated list (4 answers) Closed 10 days ago . I am storing numbers in a database with a string like 5,55,15,17,2,35 I want to remove say number 5 from the string, keeping the comma seperation set like it is. The problem with using str_replace() is that all of the 5's will be removed. If i use str_replace('5,'', $string) thats fine, but the comma wouldn't be after the 5 if it was in the middle of the string