File handling and time manipulation with lines

This is a discussion on "File handling and time manipulation with lines" within the PHP Forum section. This forum, and the thread "File handling and time manipulation with lines are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 31st, 2007, 15:27
Up'n'Coming Member
Join Date: Oct 2007
Location: london
Age: 25
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb 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: Select all
Please call MrSmith immediately. On telephone number 02392666666. Thank you.1615
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: Select all
<?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>
Thanks. eon201.
Reply With Quote

  #2 (permalink)  
Old Nov 1st, 2007, 15:49
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 21
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Re: File handling and time manipulation with lines

Quote:
Originally Posted by eon201 View Post
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
PHP: Select all


substr
("$data", -4); //gets the last 4 chrs 
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
reading a log file one line at a time depending on timestamp eon201 PHP Forum 1 Dec 4th, 2007 05:54
PHP Image Manipulation SelfconsciousSam PHP Forum 3 Jun 7th, 2006 05:46
Form handling Tim356 PHP Forum 2 Feb 28th, 2005 23:55
MSSQL string manipulation puzzle D3mon Databases 3 Oct 19th, 2004 08:14
Adjusting time from server time to local time Tim356 Classic ASP 10 Jun 21st, 2004 14:57


All times are GMT. The time now is 22:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43