PHP过滤特定的单词

My output from the mysql database looks like this: icon-search icon-white (from bootstrap framework)

And now I want, that it only displays icon-search without the icon-white string.

How can I do that?

Thanks

echo str_replace("icon-white", "", $your_output);

Or for the sake of being a little more pedantic on what icon-white strings to remove something like this would work too

echo preg_replace("/(class=[\'\"].*?)(\s*icon\-white\s*)(.*?[\'\"])/i", "\\1\\3", $your_output);

If $var contains icon-search icon white, try it this way:

$var = str_replace(' icon-white', '', $var);

If you no longer need the text icon-white, just update the values in database:

UPDATE you_table SET you_column = REPLACE(you_column, ' icon-white', '') WHERE you_conditional;

This will increase the performance of your application, but if you still need the text, then use the solution of Edd.