Jump to content

[SOLVED] preg match expression


residual

Recommended Posts

		$ch = curl_init();
	$timeout = 5; 
	curl_setopt ($ch, CURLOPT_URL, 'http://www.bungie.net/Stats/GameStatsHalo3.aspx?gameid=582493375');
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	$in = curl_exec($ch);
	curl_close($ch);
	preg_match('#<div class="community_colB" >(.+?)<!-- bottom -->#',$in, $skill);
	$skill1 = $skill[1];
	echo $skill1;

 

It echo's nothing.  Why?  I know the curl is correct it must be something with my expression but I can't figure out what, please help. :(

Link to comment
https://forums.phpfreaks.com/topic/112621-solved-preg-match-expression/
Share on other sites

couldn't get preg to work for some reason...but accomplished the same thing with:

 

<?php
  $ch = curl_init();
  $timeout = 5; 
  curl_setopt ($ch, CURLOPT_URL, 'http://www.bungie.net/Stats/GameStatsHalo3.aspx?gameid=582493375');
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $in = curl_exec($ch);
  curl_close($ch);

  $s = strpos($in,'<div class="community_colB" >');
  $e = strpos($in,'<!-- bottom -->',$s);
  if($s && $e)
    print substr($in,$s+strlen('<div class="community_colB" >'),$e-$s);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.