f



read file txt by php

sorry for my english,

I would to read a txt file and to extrapolate only  some data for to
publish on the html page
how first step i try to read and publish the file in this mode:

<?
$var=fopen("test.txt","r"); //Apro il file di testo
$leggi=fread($var,filesize("test.txt"));
$sss=nl2br($leggi);
fclose($var);
echo $sss;
?>


this is the structure of the my file:


INFO 2008/03/04 09:37:55.561 ;
source=local;
msg="xxxxxxxxxxxxx";
alerttext="kkkkkkkkkkkk";
date="Mar 04 09:37:55 2008";
END


I would want to only extrapolate following strings:
msg, alerttext, date

PS
the cycle of the text rows always begins with INFO and ends with END


thanks!!!

0
3/4/2008 9:40:15 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

12 Replies
1043 Views

Similar Articles

[PageSpeed] 56

lucabonanni@googlemail.com wrote:
> 
> 
> INFO 2008/03/04 09:37:55.561 ;
> source=local;
> msg="xxxxxxxxxxxxx";
> alerttext="kkkkkkkkkkkk";
> date="Mar 04 09:37:55 2008";
> END
> 
> 
> I would want to only extrapolate following strings:
> msg, alerttext, date
> 
> PS
> the cycle of the text rows always begins with INFO and ends with END
> 
> 
> thanks!!!
> 

Regular expressions are made for this.  If the block ALWAYS has each of 
these lines in the same order, an expression like this would work:

$count = 
preg_match_all('/INFO.*\nsource=.*;\nmsg="(.*)";\nalerttext="(.*)";\ndate="(.*)";\nEND/', 
$leggi, $parsed, PREG_SET_ORDER);

This parses out msg, alerttext, and date into arrays for each match. 
Something like this:

foreach($matches as $match)
{
	//now $match[0] is the whole block (you don't want it)
	// $match[1] is text from msg string
	// $match[2] is text from alerttext string
	// $match[3] is text from date string
}

Regular expressions are tricky, so I wouldn't be surprised if I made a 
mistake.  But try it anyway and see how it works out.  Read up on 
regular expressions if you have trouble (it's an essential skill).

Jeremy
0
jeremy44 (72)
3/4/2008 11:18:47 PM
Jeremy wrote:
> $count = 
> preg_match_all('/INFO.*\nsource=.*;\nmsg="(.*)";\nalerttext="(.*)";\ndate="(.*)";\nEND/', 
> $leggi, $parsed, PREG_SET_ORDER);
> 
> This parses out msg, alerttext, and date into arrays for each match. 
> Something like this:
> 
> foreach($matches as $match)

This should have been $parsed rather than $matches to match up with the 
preg_match_all call.  Whoops.


0
jeremy44 (72)
3/4/2008 11:19:57 PM
On 5 Mar, 00:19, Jeremy <jer...@pinacol.com> wrote:
> Jeremy wrote:
> > $count =3D
> > preg_match_all('/INFO.*\nsource=3D.*;\nmsg=3D"(.*)";\nalerttext=3D"(.*)"=
;\ndate=3D"=AD(.*)";\nEND/',
> > $leggi, $parsed, PREG_SET_ORDER);
>
> > This parses out msg, alerttext, and date into arrays for each match.
> > Something like this:
>
> > foreach($matches as $match)
>
> This should have been $parsed rather than $matches to match up with the
> preg_match_all call. =A0Whoops.

Sorry jeremy!!!!

i wrote

1<?php
2$var=3Dfopen("test.txt","r"); //Apro il file di testo
3$leggi=3Dfread($var,filesize("test.txt"));
4$sss=3Dnl2br($leggi);
5fclose($var);
6$count =3D preg_match_all('/INFO.*\nsource=3D.*;\nmsg=3D"(.*)";
\nalerttext=3D"(.*)";\ndate=3D"=AD(.*)";\nEND/', $leggi, $parsed,
PREG_SET_ORDER);
7foreach($count as $match)
8{
9        $match =3D $match * 2;
10        //now $match[0] is the whole block (you don't want it)
11        // $match[1] is text from msg string
12        // $match[2] is text from alerttext string
13        // $match[3] is text from date string
14 }
15 echo $match
16 ?>

the output on html is:
Warning: Invalid argument supplied for foreach() in C:\root\htdocs\test
\index2.php on line 7

Why???
0
3/5/2008 8:57:48 AM
lucabonanni@googlemail.com wrote:

> 7foreach($count as $match)

As Jeremy said...

foreach ($parsed as $match)


-- 
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 35 days, 16:23.]

                               Bottled Water
          http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
0
3/5/2008 10:06:12 AM
On Mar 5, 10:06=A0am, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> lucabona...@googlemail.com wrote:
> > 7foreach($count as $match)
>
> As Jeremy said...
>
> foreach ($parsed as $match)
>
> --
> Toby A Inkster BSc (Hons) ARCS
> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 35 days, 16:23.]
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Bottled Wat=
er
> =A0 =A0 =A0 =A0 =A0http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/=


To make it simple, and easily readable for a PHP novice, I'd do
this :-

$FileLines =3D file("test.txt");     // Load the file into an array
$Items =3D array();                   // Create empty array for the
items

foreach ($Line in $FileLines) {        // Read each file line into
Line
   $Parts =3D explode("=3D",$Line,2);    // Split the line, using the
equals character

   if (count($Parts) > 1) {                      //  If there was an
equals character
       $Items[$Parts[0]] =3D $Parts[1];      //  create an Items entry
keyed by the type
   }
}

echo $Items['msg'];
echo $Items['alerttext'];
echo $Items['date'];


Rob.
0
ratkinson (105)
3/5/2008 1:02:29 PM
On 5 Mar, 14:02, Rob <ratkin...@tbs-ltd.co.uk> wrote:
> On Mar 5, 10:06=A0am, Toby A Inkster <usenet200...@tobyinkster.co.uk>
> wrote:
>
> > lucabona...@googlemail.com wrote:
> > > 7foreach($count as $match)
>
> > As Jeremy said...
>
> > foreach ($parsed as $match)
>
> > --
> > Toby A Inkster BSc (Hons) ARCS
> > [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> > [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 35 days, 16:23.]
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Bottled W=
ater
> > =A0 =A0 =A0 =A0 =A0http://tobyinkster.co.uk/blog/2008/02/18/bottled-wate=
r/
>
> To make it simple, and easily readable for a PHP novice, I'd do
> this :-
>
> $FileLines =3D file("test.txt"); =A0 =A0 // Load the file into an array
> $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empty ar=
ray for the
> items
>
> foreach ($Line in $FileLines) { =A0 =A0 =A0 =A0// Read each file line into=

> Line
> =A0 =A0$Parts =3D explode("=3D",$Line,2); =A0 =A0// Split the line, using =
the
> equals character
>
> =A0 =A0if (count($Parts) > 1) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0// =A0If there was an
> equals character
> =A0 =A0 =A0 =A0$Items[$Parts[0]] =3D $Parts[1]; =A0 =A0 =A0// =A0create an=
 Items entry
> keyed by the type
> =A0 =A0}
>
> }
>
> echo $Items['msg'];
> echo $Items['alerttext'];
> echo $Items['date'];
>
> Rob.

If I understood correctly:

<?
$var=3Dfopen("test.txt","r"); //Apro il file di testo
$leggi=3Dfread($var,filesize("test.txt"));
$sss=3Dnl2br($leggi);
$FileLines =3D file("test.txt");     // Load the file into an array
$Items =3D array();                   // Create empty array for the
items


foreach ($Line in $FileLines) {        // Read each file line into
Line
   $Parts =3D explode("=3D",$Line,2);    // Split the line, using the
equals character


   if (count($Parts) > 1) {                      //  If there was an
equals character
       $Items[$Parts[0]] =3D $Parts[1];      //  create an Items entry
keyed by the type
   }



}


echo $Items['msg'];
echo $Items['alerttext'];
echo $Items['date'];
fclose($var);

?>

but the output on html is:

Parse error: parse error, unexpected T_FOREACH in C:\root\htdocs\test
\index.php on line 10

0
3/6/2008 9:31:58 AM
On Mar 6, 9:31=A0am, lbvox <lucabona...@googlemail.com> wrote:
> On 5 Mar, 14:02, Rob <ratkin...@tbs-ltd.co.uk> wrote:
>
>
>
>
>
> > On Mar 5, 10:06=A0am, Toby A Inkster <usenet200...@tobyinkster.co.uk>
> > wrote:
>
> > > lucabona...@googlemail.com wrote:
> > > > 7foreach($count as $match)
>
> > > As Jeremy said...
>
> > > foreach ($parsed as $match)
>
> > > --
> > > Toby A Inkster BSc (Hons) ARCS
> > > [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> > > [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 35 days, 16:23.]
>
> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Bottled=
 Water
> > > =A0 =A0 =A0 =A0 =A0http://tobyinkster.co.uk/blog/2008/02/18/bottled-wa=
ter/
>
> > To make it simple, and easily readable for a PHP novice, I'd do
> > this :-
>
> > $FileLines =3D file("test.txt"); =A0 =A0 // Load the file into an array
> > $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empty =
array for the
> > items
>
> > foreach ($Line in $FileLines) { =A0 =A0 =A0 =A0// Read each file line in=
to
> > Line
> > =A0 =A0$Parts =3D explode("=3D",$Line,2); =A0 =A0// Split the line, usin=
g the
> > equals character
>
> > =A0 =A0if (count($Parts) > 1) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0// =A0If there was an
> > equals character
> > =A0 =A0 =A0 =A0$Items[$Parts[0]] =3D $Parts[1]; =A0 =A0 =A0// =A0create =
an Items entry
> > keyed by the type
> > =A0 =A0}
>
> > }
>
> > echo $Items['msg'];
> > echo $Items['alerttext'];
> > echo $Items['date'];
>
> > Rob.
>
> If I understood correctly:
>
> <?
> $var=3Dfopen("test.txt","r"); //Apro il file di testo
> $leggi=3Dfread($var,filesize("test.txt"));
> $sss=3Dnl2br($leggi);
> $FileLines =3D file("test.txt"); =A0 =A0 // Load the file into an array
> $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empty ar=
ray for the
> items
>
> foreach ($Line in $FileLines) { =A0 =A0 =A0 =A0// Read each file line into=

> Line
> =A0 =A0$Parts =3D explode("=3D",$Line,2); =A0 =A0// Split the line, using =
the
> equals character
>
> =A0 =A0if (count($Parts) > 1) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0// =A0If there was an
> equals character
> =A0 =A0 =A0 =A0$Items[$Parts[0]] =3D $Parts[1]; =A0 =A0 =A0// =A0create an=
 Items entry
> keyed by the type
> =A0 =A0}
>
> }
>
> echo $Items['msg'];
> echo $Items['alerttext'];
> echo $Items['date'];
> fclose($var);
>
> ?>
>
> but the output on html is:
>
> Parse error: parse error, unexpected T_FOREACH in C:\root\htdocs\test
> \index.php on line 10- Hide quoted text -
>
> - Show quoted text -

Sorry - comes from trying to cram too many languages. That should
be :-

foreach ($FileLines as $Line)

Rob.
0
ratkinson (105)
3/7/2008 9:21:39 AM
On 7 Mar, 10:21, Rob <ratkin...@tbs-ltd.co.uk> wrote:
> On Mar 6, 9:31=A0am, lbvox <lucabona...@googlemail.com> wrote:
>
>
>
>
>
> > On 5 Mar, 14:02, Rob <ratkin...@tbs-ltd.co.uk> wrote:
>
> > > On Mar 5, 10:06=A0am, Toby A Inkster <usenet200...@tobyinkster.co.uk>
> > > wrote:
>
> > > > lucabona...@googlemail.com wrote:
> > > > > 7foreach($count as $match)
>
> > > > As Jeremy said...
>
> > > > foreach ($parsed as $match)
>
> > > > --
> > > > Toby A Inkster BSc (Hons) ARCS
> > > > [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> > > > [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 35 days, 16:23.]
>
> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Bottl=
ed Water
> > > > =A0 =A0 =A0 =A0 =A0http://tobyinkster.co.uk/blog/2008/02/18/bottled-=
water/
>
> > > To make it simple, and easily readable for a PHP novice, I'd do
> > > this :-
>
> > > $FileLines =3Dfile("test.txt"); =A0 =A0 // Load thefileinto an array
> > > $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empt=
y array for the
> > > items
>
> > > foreach ($Line in $FileLines) { =A0 =A0 =A0 =A0// Read eachfileline in=
to
> > > Line
> > > =A0 =A0$Parts =3D explode("=3D",$Line,2); =A0 =A0// Split the line, us=
ing the
> > > equals character
>
> > > =A0 =A0if (count($Parts) > 1) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0// =A0If there was an
> > > equals character
> > > =A0 =A0 =A0 =A0$Items[$Parts[0]] =3D $Parts[1]; =A0 =A0 =A0// =A0creat=
e an Items entry
> > > keyed by the type
> > > =A0 =A0}
>
> > > }
>
> > > echo $Items['msg'];
> > > echo $Items['alerttext'];
> > > echo $Items['date'];
>
> > > Rob.
>
> > If I understood correctly:
>
> > <?
> > $var=3Dfopen("test.txt","r"); //Apro ilfiledi testo
> > $leggi=3Dfread($var,filesize("test.txt"));
> > $sss=3Dnl2br($leggi);
> > $FileLines =3Dfile("test.txt"); =A0 =A0 // Load thefileinto an array
> > $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empty =
array for the
> > items
>
> > foreach ($Line in $FileLines) { =A0 =A0 =A0 =A0// Read eachfileline into=

> > Line
> > =A0 =A0$Parts =3D explode("=3D",$Line,2); =A0 =A0// Split the line, usin=
g the
> > equals character
>
> > =A0 =A0if (count($Parts) > 1) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0// =A0If there was an
> > equals character
> > =A0 =A0 =A0 =A0$Items[$Parts[0]] =3D $Parts[1]; =A0 =A0 =A0// =A0create =
an Items entry
> > keyed by the type
> > =A0 =A0}
>
> > }
>
> > echo $Items['msg'];
> > echo $Items['alerttext'];
> > echo $Items['date'];
> > fclose($var);
>
> > ?>
>
> > but the output on html is:
>
> > Parse error: parse error, unexpected T_FOREACH in C:\root\htdocs\test
> > \index.php on line 10- Hide quoted text -
>
> > - Show quoted text -
>
> Sorry - comes from trying to cram too many languages. That should
> be :-
>
> foreach ($FileLines as $Line)
>
> Rob.- Nascondi testo tra virgolette -
>
> - Mostra testo tra virgolette -

Sorry Rob. But I have created the script as it has suggested, but the
output error on html is Parse error: parse error, unexpected T_FOREACH
in C:\root\htdocs\test\luca.php on line 7



<?
$FileLines =3D file("test.txt");     // Load the file into an array
$Items =3D array();                   // Create empty array for the
items


foreach ($FileLines as $Line) {        // Read each file line into
Line
   $Parts =3D explode("=3D",$Line,2);    // Split the line, using the
equals character


   if (count($Parts) > 1) {                      //  If there was an
equals character
       $Items[$Parts[0]] =3D $Parts[1];      //  create an Items entry
keyed by the type
   }



}


echo $Items['msg'];
echo $Items['alerttext'];
echo $Items['date'];
?>
0
3/7/2008 10:04:52 AM
On Fri, 07 Mar 2008 11:04:52 +0100, lbvox <lucabonanni@googlemail.com>  =

wrote:
> Sorry Rob. But I have created the script as it has suggested, but the
> output error on html is Parse error: parse error, unexpected T_FOREACH=

> in C:\root\htdocs\test\luca.php on line 7
>
>
>
> <?
> $FileLines =3D file("test.txt");     // Load the file into an array
> $Items =3D array();                   // Create empty array for the
> items

Have you copy/pasted this literally? You do realise this last 'items' wa=
s  =

intended as a comment, and should not be on a new line? Get an editor wi=
th  =

decent syntax-highlighting, and you'll see what I mean.
-- =

Rik Wasmus
0
3/7/2008 10:17:12 AM
On 7 Mar, 11:17, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Fri, 07 Mar 2008 11:04:52 +0100, lbvox <lucabona...@googlemail.com> =A0=

> wrote:
>
> > Sorry Rob. But I have created the script as it has suggested, but the
> > output error on html is Parse error: parse error, unexpected T_FOREACH
> > in C:\root\htdocs\test\luca.php on line 7
>
> > <?
> > $FileLines =3Dfile("test.txt"); =A0 =A0 // Load thefileinto an array
> > $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empty =
array for the
> > items
>
> Have you copy/pasted this literally? You do realise this last 'items' was =
=A0
> intended as a comment, and should not be on a new line? Get an editor with=
 =A0
> decent syntax-highlighting, and you'll see what I mean.
> --
> Rik Wasmus

Sorry Rik!!!!! thank for this!!!!!!

Now the script it works!!!!!
but read only last line on the file. I would want to execute a cycle
of all the characters (items) until the end of the file and printing
(with echo) Lines for lines

here the script:

<?
$FileLines =3D file("test.txt");     // Carico il file nell' array
$Items =3D array();                   // Creao un array vuoto per
l'items

foreach ($FileLines as $Line) {        // Leggi il file linea per
linea
$Parts =3D explode("=3D",$Line,2);    // Dividi la linea letta con il
l'items uguale

   if (count($Parts) > 1) {                      //  Se il carattere =E8
uguale
       $Items[$Parts[0]] =3D $Parts[1];      //  Crea l'items con quello
trovato
   }
}

$msg =3D $Items['alerttext'];
$host =3D $Items['hostname'];
$date =3D $Items['date'];

echo "<div align=3D'center'><center> \n <table border=3D'1'> \n";
echo "<td>$date<td/>";
echo "<td>$host<td/>";
echo "<td>$msg<td/>"
?>

thanks!!
0
3/7/2008 1:01:50 PM
On Mar 7, 1:01=A0pm, lbvox <lucabona...@googlemail.com> wrote:
> On 7 Mar, 11:17, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>
>
>
>
>
> > On Fri, 07 Mar 2008 11:04:52 +0100, lbvox <lucabona...@googlemail.com> =
=A0
> > wrote:
>
> > > Sorry Rob. But I have created the script as it has suggested, but the
> > > output error on html is Parse error: parse error, unexpected T_FOREACH=

> > > in C:\root\htdocs\test\luca.php on line 7
>
> > > <?
> > > $FileLines =3Dfile("test.txt"); =A0 =A0 // Load thefileinto an array
> > > $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Create empt=
y array for the
> > > items
>
> > Have you copy/pasted this literally? You do realise this last 'items' wa=
s =A0
> > intended as a comment, and should not be on a new line? Get an editor wi=
th =A0
> > decent syntax-highlighting, and you'll see what I mean.
> > --
> > Rik Wasmus
>
> Sorry Rik!!!!! thank for this!!!!!!
>
> Now the script it works!!!!!
> but read only last line on the file. I would want to execute a cycle
> of all the characters (items) until the end of the file and printing
> (with echo) Lines for lines
>
> here the script:
>
> <?
> $FileLines =3D file("test.txt"); =A0 =A0 // Carico il file nell' array
> $Items =3D array(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Creao un array =
vuoto per
> l'items
>
> foreach ($FileLines as $Line) { =A0 =A0 =A0 =A0// Leggi il file linea per
> linea
> $Parts =3D explode("=3D",$Line,2); =A0 =A0// Dividi la linea letta con il
> l'items uguale
>
> =A0 =A0if (count($Parts) > 1) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0// =A0Se il carattere =E8
> uguale
> =A0 =A0 =A0 =A0$Items[$Parts[0]] =3D $Parts[1]; =A0 =A0 =A0// =A0Crea l'it=
ems con quello
> trovato
> =A0 =A0}
>
> }
>
> $msg =3D $Items['alerttext'];
> $host =3D $Items['hostname'];
> $date =3D $Items['date'];
>
> echo "<div align=3D'center'><center> \n <table border=3D'1'> \n";
> echo "<td>$date<td/>";
> echo "<td>$host<td/>";
> echo "<td>$msg<td/>"
> ?>
>
> thanks!!- Hide quoted text -
>
> - Show quoted text -

How many lines are there in the file?
0
ratkinson (105)
3/10/2008 11:54:33 AM
On Fri, 07 Mar 2008 14:01:50 +0100, lbvox <lucabonanni@googlemail.com>  
wrote:

> On 7 Mar, 11:17, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Fri, 07 Mar 2008 11:04:52 +0100, lbvox <lucabona...@googlemail.com> �
>> wrote:
>>
>> > Sorry Rob. But I have created the script as it has suggested, but the
>> > output error on html is Parse error: parse error, unexpected T_FOREACH
>> > in C:\root\htdocs\test\luca.php on line 7
>>
>> > <?
>> > $FileLines =file("test.txt"); � � // Load thefileinto an array
>> > $Items = array(); � � � � � � � � � // Create empty array for the
>> > items
>>
>> Have you copy/pasted this literally? You do realise this last 'items'  
>> was �
>> intended as a comment, and should not be on a new line? Get an editor  
>> with �
>> decent syntax-highlighting, and you'll see what I mean.
>
> Now the script it works!!!!!
> but read only last line on the file. I would want to execute a cycle
> of all the characters (items) until the end of the file and printing
> (with echo) Lines for lines

> <?
> $FileLines = file("test.txt");     // Carico il file nell' array

$Filelines = file('text.txt',FILE_IGNORE_NEW_LINES);

> $Items = array();                   // Creao un array vuoto per
> l'items
>
> foreach ($FileLines as $Line) {        // Leggi il file linea per
> linea
> $Parts = explode("=",$Line,2);    // Dividi la linea letta con il
> l'items uguale
>
>    if (count($Parts) > 1) {                      //  Se il carattere �
> uguale
>        $Items[$Parts[0]] = $Parts[1];

$Items[trim($Parts[0])] = trim($Parts[1]);

>    }
> }

What does a print_r($Items); give you here, or better yet:  
var_dump($Items);?

Also, you might be interested in parse_ini_file(), if the file is  
formatted (correct comments etc.) like it:  
<http://nl3.php.net/manual/en/function.parse-ini-file.php>
-- 
Rik Wasmus
0
3/10/2008 12:10:09 PM
Reply: