Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yetiboy

macrumors member
Original poster
Mar 23, 2011
35
0
I have a php script I put together that grabs info from a website and I'd like to italicize some of it. If it was the entire output it would be easy, but I only need a part of it to be italicized. So you know what I'm talking about, I'm including the code below. Incidentally, I tried just including html tags in the off chance they would work, but they don't.

yeti

Code:
<?php 

include('simple_html_dom.php');

$ch = curl_init() or die(curl_error()); 
curl_setopt($ch, CURLOPT_URL,"http://www.rotoworld.com/playernews/nfl/football-player-news"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$data1=curl_exec($ch) or die(curl_error()); 

curl_close($ch); 

$html = new simple_html_dom();

$html->load($data1);

$pb = $html->find('div[class=pb]');
$player = $html->find('div[class=player]');

foreach($player as $post){
	$position = preg_replace("#<a.*?>.*?</a>#","",$post);
	$playerinfo[] = array($post->children(0)->innertext." ".trim(strip_tags($position))." ".$post->children(1)->innertext);
}

$report = $html->find('div[class=report]');

foreach($report as $post){
	$playerreport[] = array($post->children(0)->innertext);
}

$impact = $html->find("div[class=pb]");

foreach($impact as $post){
	$pos1 = strpos($post, '<div class="impact">')+20;
	$pos2 = strpos($post, '<div class="info">')-6;
	$len = $pos2 - $pos1;
	$impactfinal[] = array(substr($post, $pos1, $len-10));
}

for ($i = 0; $i<=5; $i++){
	echo str_replace(""", "'", $playerinfo[$i][0]), PHP_EOL;
	echo str_replace(""", "'", $playerreport[$i][0]), PHP_EOL;
	echo trim(str_replace(""", "'", $impactfinal[$i][0])), PHP_EOL, PHP_EOL;
}

?>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.