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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.