webForumDet fria alternativet

Highlighta rad som innehåller specifikt ord

PHP

0 svar · 413 visningar · startad av COOBRAA

Medlem sedan nov. 200416 inlägg
Frågan#1

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?

276 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
128 ms — deklarationer (db)
0 ms — hämta statistik (cache)
145 ms — hämta tråd, inlägg och bilagor (db)
125 ms — ändringar (db)