Location: PHPKode > scripts > The Anti-Diet Pill > the-anti-diet-pill/anti-diet-pill-files/includes/functions.php
<?php
	function getCustomTagContent($tag,$contents) {
		$start_tag = '<' . $tag . '>';
		$end_tag = '<\/' . $tag . '>';
		preg_match("/" . $start_tag . "(.+)" . $end_tag . "/i", $contents, $match);
		return $match[1];
	}
	
	function getFileContents($full_filename,$keep_newlines='0') {
		
		if ($fp = @fopen($full_filename,'r')) {
			$contents = fread($fp, filesize($full_filename));
			fclose($fp);
			if ($keep_newlines == 0) {
				$contents = str_replace("\n",'',$contents);
			}
		} else {
			echo 'oops';
		}
		return $contents;
	}
	
	function getTipsData($file) {
		$contents = getFileContents($file);
		$data_array = explode('</tip>',$contents);
		$total = count($data_array) - 1;
		$tip_i = 0;
		while ($data_array[$tip_i] != '') {
			$tip[$tip_i]['title'] = getCustomTagContent('title',$data_array[$tip_i]);
			$tip[$tip_i]['text'] = getCustomTagContent('text',$data_array[$tip_i]);
			$tip_i++;
		}
		$tip['count'] = $total;
		return $tip;
	}
	
?>
Return current item: The Anti-Diet Pill