I'm doing a cart system, when a client select various items the data is sent as string with IDs and comma as delimiter, example: 1,2,3
I save that to the database and I can show each item description using a custom function and foreach. The problem is if a client want to remove a item, how should I proceed to update the new changes to the DB? Because I tried with str_replace and I can only remove the ID but keeps the delimiter (comma), example: 1,2,
or 1,,3
Any ideas or suggestions how can I improve this? Thank you for your time.
Regards.