/    Sign up×
Community /Pin to ProfileBookmark

File handling and time manipulation with lines

Hi,

Ive come across something that i just dont know how to approach.
Basically I have two pages of php.

Page 1 creates a file with lines of data, each line of data looks like this:

[code]Please call MrSmith immediately. On telephone number 02392666666. Thank you.1615[/code]

Now what I need to do with this data is take the last 4 digits of the strings (which are individual stamps of time etc 4:15pm) and work out:
1.How many lines appearred within the last hour.
2.If the last line is new (which would only be true if the time stamp on the line is equal to the current one of date(‘Gis’).

Here is how far I have come so far. Any help would be greatly appreciatted.

[code]
<?php
$filename = ‘phonecsv/’. date(‘ymd’). ‘.csv’;

if (file_exists($filename))
{
$fp = fopen($filename, “r”);

// works out how many callback requests today
$lines = count(file($filename));
echo “Today there have been $lines callback requests <br/>”;

// needs to work out from time sequence how many in last hour
echo “In the last hour there have been x callback requests<br/>”;

// needs to work out from time sequence if new message
echo “This is the latest callback request<br/>”;

$data = fgets($fp);
}

else
{
echo “The file $filename does not exist!! Check the svr file and callback forwarder!<br/>”;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>

<body>
<?php
echo $data;
?>

<script type=”text/javascript”>
// set the page to reload every 20 sec
setTimeout(‘window.location.href = ‘<?php echo $_SERVER[‘php_self’]; ?>’, 20);
</script>
</body>
</html>
[/code]

Thanks. eon201.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@chestertbNov 01.2007 — Do you have access to MySQL or some other formal database?

And do you control the script that's writing the data?
×

Success!

Help @dan_coop3r spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...