Jump to content

Can't iterate my array


dbillings

Recommended Posts

I can't get my array's to echo. The diplay pukes out the following.

 

IP: Array Unix:

IP: Array Unix:

 

<?php

##############################
### Users online script
### ver. 8/26/07
##############################

$ip = $_SERVER['REMOTE_ADDR'];

$filename = "usersonline.txt";

if (is_writable($filename)) {

$handle = fopen($filename, "r");

if (filesize($filename) > 0) {


	$contents = fread($handle, filesize($filename));

	fclose($handle);

}

$handle = fopen($filename, "a");

$iptime = $_SERVER['REMOTE_ADDR']."@@@@".time()."****";

$seperate = explode("****", $contents);

$remote_addr = array();

$time_out = array();

foreach ($seperate as $value) {

	list($remote_addr[], $time_out[]) = split('@@@@', $seperate);

}

if (count($remote_addr) == count($time_out)) { 

	$counter = count($remote_addr);

	for ($i=0; $i < $counter; $i++) { // I cant' get this array to display.  
					  // Neither $remote_addr nor $time_out display. Any ideas?

		echo "IP: ";
		echo $remote_addr[$i];
		echo " Unix: ";
		echo $time_out[$i];
		echo " <br />";

	}


}

if (fwrite($handle, $iptime) === FALSE) {

	echo "File: $filename cannot be written too.";

	exit;

}

fclose($handle);
}else{

echo "The $filename is not writable.";

}
?>

Link to comment
https://forums.phpfreaks.com/topic/66967-cant-iterate-my-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.