By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

skip line begin with #

P: 44
hi all

i am having a problem with reading the lines from the text file

my file look like this:

#"11-02-2008 " chief vs tumi "1234"
"12-02-2008 " duma vs duma "1254"
i am wondering if the is any function that will can help me to skip the line begin with hash.
Feb 11 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 4,258
Show (part of) the reading code, because you can either read a file 'at-once', in an array or line-by-line.

Feb 11 '08 #2

P: 44
$found = "#"; // need to be serch
$lines = file.txt; //text file
if ($lines)


foreach($lines as $lineNumber) //loop throuhg line by line


$foundAMatch = preg_match("^$found", $lineNumber, $matches, PREG_OFFSET_CAPTURE);//regular expression to serch

if ($foundAMatch > 0)


$found = $matches[0][0];



$str_array = explode(" ",$count);

echo $str_array[0]."<br/>";




$line="no file/folder found";

echo $line;


if you can help me to skip the line beggin with hash cause they always gives me a problem when i read from the file.
Feb 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.