Hi,

I'm having a strange problem. The task: search on a site and get the all the dates from a particular season. Everything goes well for all the mondays, tuesdays, ... , saturday. But at Sunday I only get 2 results and I need 11 results. Now when I only search for Sunday it does give me 11 results.

Does anyone know what could be the problem? Is an array only limited to 80 values? Because I get only 80 results (but I should be 89).


Here is the script:

$html1 = "http://sports.espn.go.com/nba/teams/schedule?team=" . $datateam . "&year=2007";

$array1 = file_get_contents($html1);

preg_match_all('/<nobr>Mon, ([\s\d\w]+)/',$array1,$mon);

for($c=0;$c < count($mon[1]);$c++){

	$explode = explode(" ", $mon[1][$c]);

	$dag1[$c] = $explode[1];
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		$maand1[$c] = "10";
		$jaar1[$c] = "2006";
	}elseif($maand1explode == "Nov"){
		$maand1[$c] = "11";
		$jaar1[$c] = "2006";
	}elseif($maand1explode == "Dec"){
		$maand1[$c] = "12";
		$jaar1[$c] = "2006";
	}elseif($maand1explode == "Jan"){
		$maand1[$c] = "1";
		$jaar1[$c] = "2007";
	}elseif($maand1explode == "Feb"){
		$maand1[$c] = "2";
		$jaar1[$c] = "2007";
	}elseif($maand1explode == "Mar"){
		$maand1[$c] = "3";
		$jaar1[$c] = "2007";
	}elseif($maand1explode == "Apr"){
		$maand1[$c] = "4";
		$jaar1[$c] = "2007";
	}elseif($maand1explode == "May"){
		$maand1[$c] = "5";
		$jaar1[$c] = "2007";
	}elseif($maand1explode == "Jun"){
		$maand1[$c] = "6";
		$jaar1[$c] = "2007";
	}
}

preg_match_all('/<nobr>Tue, ([\s\d\w]+)/',$array1,$tue);

for($d=0;$d < count($tue[1]);$d++){

	$explode = explode(" ", $tue[1][$d]);

	array_push($dag1,$explode[1]);
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		array_push($maand1,"10");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Nov"){
		array_push($maand1,"11");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Dec"){
		array_push($maand1,"12");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Jan"){
		array_push($maand1,"1");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Feb"){
		array_push($maand1,"2");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Mar"){
		array_push($maand1,"3");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Apr"){
		array_push($maand1,"4");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "May"){
		array_push($maand1,"5");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Jun"){
		array_push($maand1,"6");
		array_push($jaar1,"2007");
	}
}

preg_match_all('/<nobr>Wed, ([\s\d\w]+)/',$array1,$wed);

for($e=0;$e < count($wed[1]);$e++){

	$explode = explode(" ", $wed[1][$e]);

	array_push($dag1,$explode[1]);
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		array_push($maand1,"10");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Nov"){
		array_push($maand1,"11");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Dec"){
		array_push($maand1,"12");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Jan"){
		array_push($maand1,"1");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Feb"){
		array_push($maand1,"2");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Mar"){
		array_push($maand1,"3");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Apr"){
		array_push($maand1,"4");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "May"){
		array_push($maand1,"5");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Jun"){
		array_push($maand1,"6");
		array_push($jaar1,"2007");
	}
}

preg_match_all('/<nobr>Thu, ([\s\d\w]+)/',$array1,$thu);

for($f=0;$f < count($thu[1]);$f++){

	$explode = explode(" ", $thu[1][$f]);

	array_push($dag1,$explode[1]);
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		array_push($maand1,"10");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Nov"){
		array_push($maand1,"11");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Dec"){
		array_push($maand1,"12");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Jan"){
		array_push($maand1,"1");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Feb"){
		array_push($maand1,"2");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Mar"){
		array_push($maand1,"3");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Apr"){
		array_push($maand1,"4");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "May"){
		array_push($maand1,"5");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Jun"){
		array_push($maand1,"6");
		array_push($jaar1,"2007");
	}
}
preg_match_all('/<nobr>Fri, ([\s\d\w]+)/',$array1,$fri);

for($g=0;$g< count($fri[1]);$g++){

	$explode = explode(" ", $fri[1][$g]);

	array_push($dag1,$explode[1]);
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		array_push($maand1,"10");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Nov"){
		array_push($maand1,"11");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Dec"){
		array_push($maand1,"12");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Jan"){
		array_push($maand1,"1");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Feb"){
		array_push($maand1,"2");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Mar"){
		array_push($maand1,"3");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Apr"){
		array_push($maand1,"4");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "May"){
		array_push($maand1,"5");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Jun"){
		array_push($maand1,"6");
		array_push($jaar1,"2007");
	}
}

preg_match_all('/<nobr>Sat, ([\s\d\w]+)/',$array1,$sat);

for($h=0;$h < count($sat[1]);$h++){

	$explode = explode(" ", $sat[1][$h]);

	array_push($dag1,$explode[1]);
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		array_push($maand1,"10");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Nov"){
		array_push($maand1,"11");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Dec"){
		array_push($maand1,"12");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Jan"){
		array_push($maand1,"1");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Feb"){
		array_push($maand1,"2");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Mar"){
		array_push($maand1,"3");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Apr"){
		array_push($maand1,"4");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "May"){
		array_push($maand1,"5");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Jun"){
		array_push($maand1,"6");
		array_push($jaar1,"2007");
	}
}

preg_match_all('/<nobr>Sun, ([\s\d\w]+)/',$array1,$sun);

for($j=0;$j < count($sun[1]);$j++){

	$explode = explode(" ", $sun[1][$j]);

	array_push($dag1,$explode[1]);
	$maand1explode = $explode[0];

	if($maand1explode == "Oct"){
		array_push($maand1,"10");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Nov"){
		array_push($maand1,"11");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Dec"){
		array_push($maand1,"12");
		array_push($jaar1,"2006");
	}elseif($maand1explode == "Jan"){
		array_push($maand1,"1");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Feb"){
		array_push($maand1,"2");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Mar"){
		array_push($maand1,"3");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Apr"){
		array_push($maand1,"4");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "May"){
		array_push($maand1,"5");
		array_push($jaar1,"2007");
	}elseif($maand1explode == "Jun"){
		array_push($maand1,"6");
		array_push($jaar1,"2007");
	}
}


// Expert ID
//
//
for($x=0; $x < count($expertname);$x++){

	$urlexpert = "http://spaces.covers.com/" . $expertname[$x] . "?t=0";

	$urlexpertstring = file_get_contents($urlexpert);
	preg_match('/user=([-0-9]+)&amp;/',$urlexpertstring,$matchexpert);
	$expertid[$x] = $matchexpert[1];

	if($expertid[$x] == ""){
		preg_match('/userID=([\d]+)/',$urlexpertstring, $matchexpertextra);
		$expertidfinal = $matchexpertextra[1];
	}else{
		$expertidfinal = $expertid[$x];
	}

	$expert[$x] = $expertidfinal;
}

for($k=0;$k<count($dag);$k++){
	
	print("'" . $dag1[$k] . "-" . $maand1[$k] . "-" . $jaar1[$k]);
	?><br><?
	
}

Grtz

Dani AI

Generated

The most likely cause is a simple indexing/typo at the end of your script rather than an “80 item” array limit. In your final print loop you iterate up to count($dag) while your scraped results live in $dag1, $maand1 and $jaar1. If $dag has fewer entries you will only print that many — which explains the nine missing Sunday rows. Change the loop to use the actual arrays (or loop to the minimum length of the three arrays) and the missing items should appear. Example of a safe print loop:

$total = min(count($dag1), count($maand1), count($jaar1));
for ($k = 0; $k < $total; $k++) {
    echo $dag1[$k] . '-' . $maand1[$k] . '-' . $jaar1[$k] . "<br>\n";
}

Quick debugging checklist:

  • Confirm array lengths immediately after building them: var_dump(count($dag1), count($maand1), count($jaar1));.
  • Remove unrelated sections (as pointed out, the expert-ID block) while debugging so they cannot influence indexing.
  • After any preg_match_all() call, check preg_last_error() to detect PCRE issues: see the manual for details (the function reports backtrack/recursion errors and others) preg_last_error.

If you still lose matches, the problem can be HTML variability (non‑breaking spaces, extra tags or entities around the date). Normalize entities with html_entity_decode() or use a DOM approach — DOMDocument + DOMXPath is far more robust than brittle regex for scraping structured HTML (see html_entity_decode and DOMDocument).

The expert-ID party isn't needed here!

This means that the last lines SHOULD look like:

10-12-2006
17-12-2006
11-2-2007
25-2-2007
4-3-2007
11-3-2007
1-4-2007
15-4-2007

These are the 9 result I don't get, only when I make a request for sunday and delete the other searches(mondag, ..., saturday).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.