Delete a word from a string in mysql row
Am trying to delete a word from a string in my database
The string is $keywords = tech,sms,libya,tax
S开发者_StackOverflowuppose i want to remove libya from the string how do i go about this
I think for the clarity you might want to explode the string into an array, remove the unwanted element and then reconstruct the string. Like this:
$keywords = 'tech,sms,libya,tax'; // Set String
$keywords = explode(',', $keywords); // Explode into array
unset($keywords[ array_search('libya', $keywords) ]); // Unset the array element with value of 'libya'
$keywords = implode(',',$keywords); // Reconstruct string
Use MySQL's REPLACE function.
精彩评论