I want the a good compact and fast PHP function to display to the browser, any text that user insert it to my site:
function TextProcessing($text, $color= array(), $wrap = 0, $url = 0, $br = 0){
// first of all, convert html special chars, using for example htmlspecialchars()
// $color uses when user search for some text
if(count($color)) // then color array's item with red
// $wrap is any number
if($wrap) // then apply something like: $text = wordwrap($text, $wrap, "<wbr />", 1);
// $url 0 or 1
if($url) // then convert http/https/ftp text url to html url
// $br 0 or 1
if($br) // then apply something like: $text = nl2br($text);
return $text
}
Try this example:
$text = '
tex
t <[login to view URL]> and
te xt (<[login to view URL]>;) and **abce 5>4 "sdf" <
text <ftp://[login to view URL]>{ and**
**
one more <[login to view URL]> end
<[login to view URL]>
';**
**echo TextProcessing($text, array("and ab","com","&","5>","\""), 40, 1, 1);**
**So, in this example, all urls must be converted to clickable urls. All words longer than 40 chars, including urls, must be wrapped. The items ("and ab","com","&","5>","\"") must be colored by red,... Good luck.**
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
4) Make sure the function is working fine with this example:
$vText = '
tex
t <[login to view URL]> and
te xt (<[login to view URL]>;) and 5>4 "sdf"
text [rul[login to view URL](that is it):[ and <br>
text [ftp://[login to view URL]{ and </div>
one more <[login to view URL]> end
<[login to view URL]>
hi....
<[login to view URL]>
ThereIsNoSpaceBetweenThisLineAndTheLineAboveItIsOnlyNewLineAndThisLine<font color=\'red\'>khalid</font>IsLongLineThereIsNoSpaceBetweenThisLineAndTheLineAboveItIsOnlyNewLineAndThisLin<b>0000</b>eIsLongLineThereIsNoSpaceBetweenThisLineAndTheLineAboveItIsOnlyNewLineAndThisLineIsLongLine
the End. ..
';
//$vWrap=40;
echo "<html><head><title>Text</title></head><body>";
echo funText($vText, array("text","com","&","5>","<br>"), 40, 1, 1);
echo "</body></html>";
* * *This broadcast message was sent to all bidders on Sunday Jan 14, 2007 1:00:51 PM:
I add this to my bid:
4) Make sure the function is working fine with this example:
$vText = '
tex
t [login to view URL] and
te xt ([login to view URL];) and 5>4 "sdf"
text [rul[login to view URL](that is it):[ and
text [ftp://[login to view URL]{ and
one more [login to view URL] end
[login to view URL]
hi....
[login to view URL]
ThereIsNoSpaceBetweenThisLineAndTheLineAboveItIsOnlyNewLineAndThisLinekhalidIsLongLineThereIsNoSpaceBetweenThisLineAndTheLineAboveItIsOnlyNewLineAndThisLin**0000**eIsLongLineThereIsNoSpaceBetweenThisLineAndTheLineAboveItIsOnlyNewLineAndThisLineIsLongLine
the End. ..
';
//$vWrap=40;
echo "";
echo funText($vText, array("text","com","&","5>","
"), 40, 1, 1);
echo "";
## Platform
Linux
Apache2
PHP5