[thelist] PHP Array loop help

CDitty mail at redhotsweeps.com
Fri May 10 11:30:00 CDT 2002


Thanks all, I actually goofed when I posted my code.  Here is a more
accurate example....

Thanks

Chris

<?
if(!IsSet($HTTP_COOKIE_VARS["test"])){
	setcookie("test", "43|50|77|84|", time()+31536000);  /* expire in 1 year */
}

$myCookie = explode("|",$HTTP_COOKIE_VARS["test"]);

foreach ($myCookie as $v){
	echo $v . "<br>";

	$links_database = "/data/links.db";
	$fd = fopen($links_database, "r");
	$contents = fread($fd, filesize($links_database));

	$cookieInfo = explode("|", $contents);

	while(list($key, $value) = each($cookieInfo)){
   		if($v == $value){ // Must match value.
		// Value is the ID number that is matched in the cookie above
			print "Link Info: $value\n<br>";
		}
	}
	fclose($fd);
}
?>

Here is the expected result....(one for each match)
Link Info: 43
Link Info: Killer Brownie Drawing
Link Info: http://www.dorothylane.com/departments/killerbrowniedrawing.html
Link Info: 03-Feb-98
Link Info: Daily/Food_Edibles_Cooking
Link Info:
Link Info: Continental US
Link Info: 3 World Famous Killer Brownie Brownies
Link Info: Ongoing
Link Info: One entry per day
Link Info: Weekly drawing
Link Info: 6505
Link Info: No
Link Info: Yes
Link Info: 8.00
Link Info: 1
Link Info:
Link Info: No



Here is the actual result.....
43
Link Info: 43
Link Info: 43
Link Info: 43
Link Info: 43
50
Link Info: 50
Link Info: 50
Link Info: 50
77
Link Info: 77
Link Info: 77
Link Info: 77
Link Info: 77
84
Link Info: 84
Link Info: 84
Link Info: 84

Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
Link Info:
...........




More information about the thelist mailing list