Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-21-2010, 05:33 PM   #1
New Member
 
Join Date: Nov 2010
Posts: 1
Default Help Find random numbers in a .txt ore .rtf File

What i want it to do is to find all the lines that contains a row of numbers.
In this case no less then 4 numbers after etche other.

This is the code i got and it displays a blank page when the file contains 1234 in a line in the .txt file. tryd using it .rtf as well same result blank page.

Here is the Code:
<?php
// the file has been uploaded.
// (do it yourself)
$file = 'file.txt';
// the minimum length of each number
$min = 4;

$matches = array ();
foreach (file ($file) as $k => $line)
{
if (preg_match ('/^[\d]{' . $min . ',}+$/', $line))
{
$matches[] = $k;
}
}

if (sizeof ($matches))
{
// dumps line numbers with positive match
print_r ($matches);
}
?>

All help is most welcome.
Sorry if my gramma isent perfect i hawe some problems white spelling.
WetCode is offline   Reply With Quote


Reply

Thread Tools
Display Modes

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



All times are GMT. The time now is 05:42 PM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.