function find_quotes_in_post($id , $post_body , $type = NULL) { if($type != NULL) { $query = "SELECT * FROM forum_" . (($type == TOPIC) ? "topics" : "posts") . " WHERE id = '" . $id . "'"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $poster_id = $row["posterid"]; $body = $row["body"]; $stamp = $row["timestamp"]; $date = date("F j, Y, g:i a" , $stamp); $str .= "
"; } $strings = array(); $replace = array(); preg_match_all('|#QUOTE_TOPIC_(\d+)#|', $post_body, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $strings[] = $match[0]; $replace[] = $str; } $post_body = str_replace($strings, $replace, $post_body); preg_match_all('|#QUOTE_POST_(\d+)#|', $post_body, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $strings[] = $match[0]; $replace[] = $str; } $post_body = str_replace($strings, $replace, $post_body); return $post_body; } } }