开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜