•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,745 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 770 | Replies: 3
![]() |
•
•
Join Date: Sep 2007
Location: India
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
I have enclosed the simple PHP function for Text [array] Highlight
without changing the own case...
without changing the own case...
function ShowPowerHighlight($Text,$Needle) {
for($j=0; $j< count($Needle); $j++){
if ($Needle[$j] != "") {
$TextTemp = "";
$i=0;
while($i if((($i + strlen($Needle[$j])) <= strlen($Text))
&& (strcasecmp($Needle[$j], substr($Text, $i,
strlen($Needle[$j]))) == 0)) {
$TextTemp .= '' . substr($Text, $i ,
strlen($Needle[$j])) . '';
$i += strlen($Needle[$j]);
}else {
$TextTemp .= $Text{$i};
$i++;
}
}
$Text = $TextTemp;
$TextTemp="";
}
}
return $Text;
}
$Text= "The PHP Hypertext Preprocessor is a programming language that
allows web developers to create dynamic content that interacts with
databases" ;
$Needle= array ("0" =>"PHP","1"=>"web","2"=>"to","3"=>"byet");
echo ShowPowerHighlight($Text,$Needle);•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation:
Rep Power: 3
Solved Threads: 71
•
•
Join Date: Sep 2007
Location: India
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
I have enclosed the simple PHP function for Text [array] Highlight
without changing the own case...
without changing the own case...
function ShowPowerHighlight($Text,$Needle) {
for($j=0; $j< count($Needle); $j++){
if ($Needle[$j] != "") {
$TextTemp = "";
$i=0;
while($i<strlen($Text)){
if((($i + strlen($Needle[$j])) <= strlen($Text)) && (strcasecmp($Needle[$j], substr($Text, $i, strlen($Needle[$j]))) == 0)) {
$TextTemp .= '<font style="background-color:#FFFF00">' . substr($Text, $i , strlen($Needle[$j])) . '</font>';
$i += strlen($Needle[$j]);
}else {
$TextTemp .= $Text{$i};
$i++;
}
}
$Text = $TextTemp;
$TextTemp="";
}
}
return $Text;
}
$Text= "The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases" ;
$Needle= array ("0" =>"PHP","1"=>"web","2"=>"to","3"=>"byet");
echo ShowPowerHighlight($Text,$Needle); "The fear of the Lord is the beginning of wisdom"
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Javascript Function return value into PHP or not ?? Please help !! (JavaScript / DHTML / AJAX)
- PHP detect space function (PHP)
- PHP Help - Display forum online and total members on main page (PHP)
- [Revised] vBulletin Mod_rewrite Tutorial (PHP)
- Image Resize Function Error (PHP)
- How in PHP get ResultSet of PostGreSql-function? (PHP)
- PHP and MySQL Web Development (PHP)
- How can i call c++ functions in php? (PHP)
- Features in PHP 5 (PHP)
Other Threads in the PHP Forum
- Previous Thread: How to parse php code in htm file?
- Next Thread: Using mysqli_bind_param with an unknown number of variables


Linear Mode