LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 07-07-2004, 03:47 AM   #1
blackzone
Member
 
Registered: Jul 2004
Posts: 256

Rep: Reputation: 30
use php script to parse a file.


if I have a file such as >>

"
FirstLine
SecondLINE DONTWANT
Third WANT 1.2.3
FORTH DONTWANT
"

what is the best way to use php script to capture the number after WANT

ie(I want to capture the string "1.2.3")
 
Old 07-07-2004, 05:43 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
PHP Code:
<?php
$lines 
file"your_file.txt" );

for( 
$i 0$i sizeof($lines); $i++ )
{
    if (
preg_match("/\\d\\.\\d\\.\\d/"$lines[$i]) )
    {
        
$str ereg_replace"^(.*) """$lines[$i] );
        echo 
"$str\n";
    }
}
?>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Script to parse Word/RTF Documents saravanan1979 Programming 10 02-18-2010 08:25 AM
PHP parse error in config.inc.php.in Confusedious Linux - Software 2 11-03-2005 06:08 AM
Need help with perl/bash script to parse PicBasic file cmfarley19 Programming 13 11-18-2004 06:06 PM
php script can not write text file lemotion Linux - Newbie 5 04-20-2004 11:14 PM
How to read ans parse MS word file using a Linux Shell script. Alek Linux - General 2 11-10-2003 03:07 PM


All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration