In the spirit of evolution and improvement of the forum on behalf of a better community I came into a new BBcode addition to perform a search in the forum.
The new BBcode I would like to suggest are the following, for example:
Code: Select all
їsearch]evolution and better and communityї/search]
and
їsearch=scorphus]evolution and better and communityї/search]Here is a code with the regular expressions and the replacement strings:
Code: Select all
<?php
//[search]keywords[/search]
$regExp = "#\[search\](.*?)\[/search\]#si";
if (preg_match($regExp, $str, $regs)) {
$rep = '<a href="http://forums.devnetwork.net/search.php?search_keywords=$1">$1</a>';
$str = preg_replace($regExp, $rep, $str);
}
//[search=author]keywords[/search]
$regExp = "#\[search=(.*?)\](.*?)\[/search\]#si";
if (preg_match($regExp, $str, $regs)) {
$rep = '<a href="http://forums.devnetwork.net/search.php?search_keywords=$2&search_author=$1">$2 (by $1)</a>';
$str = preg_replace($regExp, $rep, $str);
}
?>I hope it is ready to be added to the forum.
Cheers,
Scorphus.