array key exists problem with a loop

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
xcow
Forum Newbie
Posts: 5
Joined: Sat Feb 24, 2007 10:21 am

array key exists problem with a loop

Post by xcow »

edit// sry i edited the page cause the php code was the wrong one
edit2// sry, this has been solved. thanks =p

Code: Select all

function read($file,$startNo=0) {
		global $xf_root_path,$xf_config_global_extention,$xf_config_postsystem_posts_per_page,$xf_dir_postlogs;
		$filename = $file.$xf_config_global_extention;
		$fullpath = $xf_root_path.$xf_dir_postlogs.$filename;
		
		$linesx = file($fullpath);
		$lines = array_reverse($linesx);
		
		
		
		while (list($key,$value) = each($lines)) {
			if (($key >= $startNo) && ($key < ($startNo+$xf_config_postsystem_posts_per_page))) {
				$output[$key] .= $value;
			}
		}
		
		return $output;
	}
that is my function for getting back x number of posts. But i keep getting UNDEFINED OFFSET errors.. any help appreciated

-thanks
Last edited by xcow on Wed Feb 28, 2007 7:28 am, edited 2 times in total.
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

Post by ryuuka »

i'm guessing that $key or $value or $lines isn't an array and that one of these needs to be an array
Post Reply