?Include/Req dynamic file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Sky
Forum Commoner
Posts: 71
Joined: Wed Oct 02, 2002 4:00 pm

?Include/Req dynamic file?

Post by Sky »

Code: Select all

<? 
global $bsnews;
function file_to_array($news_url, $seperator)
{
	//Get Contents
		$bsnews['prearray'] = require($news_url);
	//Strip tags
		$bsnews['prearray'] = strip_tags($bsnews['content']);
	//Add Delimiters
		$bsnews['prearray'] = str_replace("2003", "|2003", $bsnews['prearray']);
	//Add ending delmiter
		$bsnews['prearray'] .= $seperator;
	//Explode to level one
		$bsnews['array'] = explode($seperator, $bsnews['prearray']);
	//Remove Blank Keys
		$bsnews['array'] = array_slice($bsnews['array'], 1, -1);
	//Loop and explode to level two
		for($i = 0; $i < count($bsnews['array']); $i++)
		{
			//Explode Key
				$bsnews['array2'][$i] = explode("	", $bsnews['array'][$i]);
			//Assign Key0 to Date
				$bsnews['final'][$i]['date'] = $bsnews['array2'][$i]['0'];
			//Assign Key1 to Contest
				$bsnews['final'][$i]['contest'] = $bsnews['array2'][$i]['1'];
			//Assign Key2 to Content
				$bsnews['final'][$i]['content'] = $bsnews['array2'][$i]['2'];
		}
		//Return $BattleSpotNews
			return $bsnews;
}
//Test function
	file_to_array("http://www.battlespot.com/mindrover/news/dump?r=", "|");
//Additional Test, Print the array.
	print_r($bsnews['final']);
?>
Last edited by Sky on Sun Feb 16, 2003 8:10 am, edited 1 time in total.
User avatar
Sky
Forum Commoner
Posts: 71
Joined: Wed Oct 02, 2002 4:00 pm

Post by Sky »

Ok, I can now stick a .txt on the end of the file if that would help, but the other issue is it's off-server. If I can still get it, can I get some input as to how?
User avatar
Sky
Forum Commoner
Posts: 71
Joined: Wed Oct 02, 2002 4:00 pm

Post by Sky »

hate to do this, but i couldn't get any help on the irc channel so bump.
Post Reply