php - Strip first word from a string -


i have script lets users post comments have setup @ begin of every comment user put in script puts in hate automactically how want work, user put in hating , comes out hating hating , users comment. have ideas on how can strip out hating or hates if first word in sentence inputted user? @ moment have set remove hating removes ever used in sentence not @ moment. here of code being used.

if (strpos($content, 'hating') !== false) {   $content = str_replace("hating", "", $content);   }    $query="insert posts set story='hating ".mysql_real_escape_string($content)."', time_added='".time()."', date_added='".date("y-m-d")."', active='$active', pip='".$_server['remote_addr']."'";    $result=$conn->execute($query);   $pid = mysql_insert_id(); 

set story='hating " have set put in word hating , include in database when submitted.

try:

$content = preg_replace("(^hating )","",$content); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -