---
title: "Highlighta rad som innehåller specifikt ord"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/153927-highlighta-rad-som-innehåller-specifikt-ord"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "COOBRAA"
published: "2006-11-19T10:40:07.000Z"
updated: "2006-11-19T10:40:07.000Z"
replies: 0
views: 418
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/153927-highlighta-rad-som-innehåller-specifikt-ord"
---

# Highlighta rad som innehåller specifikt ord

## #1 — COOBRAA, 2006-11-19T10:40Z

Hej, 

plockar ut en serietabell från en extern sida med följande kod

```
<table border="0" cellspacing="0" cellpadding="0"> 
<tr style="font-size: 11px; font-family: Tahoma; color: #FFFFFF"> 
<td width="100">&nbsp</td> 
<td width="50" align="center"><b>&nbsp</b></td> 
<td width="30" align="center"><b>&nbsp</b></td> 
<td width="30" align="center"><b>&nbsp</b></td> 
<td width="30" align="center"><b>&nbsp</b></td> 
<td width="60" align="center"><b>&nbsp</b></td> 
<td width="30" align="center"><b>&nbsp</b></td> 
</tr> 
<?php 
$site = file_get_contents("http://www.svenskfotboll.se/goteborg/Table.ASP?TournamentId=37436"); 
 
preg_match_all('/<a href=\"organisation.*?\/a>/i', $site, $team); // Lagen 
preg_match_all('/<td align=\"center\" nowrap>(.*?)<\/td>/i', $site, $matches); // resultaten 
$list = array_chunk($matches[1],6); 
unset($matches); //släng bort $matches, den har gjort sitt 
 
 
foreach($team[0] as $key => $value) { 
$i++; //räknare 
 
// Rätta till länkarna... 
$team = preg_replace('/<a href=\"(.*\")>/', '<a hhref="http://www.svenskfotboll.se/goteborg/\\1 target="_blank">', $value); 
 
// Bakgrundsfärg... 
$color = ($color == "#aa0000") ? "#aa0000" : "#aa0000"; 
 
// Skriv ut tabellen 
echo("<tr height=20 bgcolor=\"$color\"><td width=90 align=left style=\"font-family: Tahoma; font-weight: bold; color: #FFFFFF; font-size: 11px\"> $team</td>\n"); 
 
   // loopa ut resultaten 
   for($t=0; $t < 6; $t++) { 
   echo("<td align=center style=\"font-family: Tahoma; color: #FFFFFF; font-size: 11px\">". $list[$key][$t] ."</td>\n"); 
   } 
    
echo("</tr>\n"); 
} 
?> 
</table>
```

Är det möjligt att skriva ut raden som innehåller önskat lag med fet stil, typ highlight-a?

Permalänk: https://www.webforum.nu/p/153927

---

Tråden på webben: https://www.webforum.nu/amne/php/153927-highlighta-rad-som-innehåller-specifikt-ord
