I want to be able to easily and quickly delete an array of needles from a haystack array. In actual fact I have a comma separated list of numbers (though this is a string i know) that need to be deleted from a second comma separated list of number that I pull from a field in my sql database.
So I need -
$orig_needle_list = "3456,5678"; The haystack list is in a field in a mysql database and is "3456, 4567, 5678, 6789" - so I basically want to update this field to "4567,6789"
Q1. Should I retrieve the haystack list, convert both to arrays and iterate over them with a nested foreach cycle and array_splice any matched values?
Q2 Can I use in_array to be faster than nested foreach method?
Q3 is there a way to cut out the middle man and update the field by performing this in an sql query?
thanks