I'm trying that my php script reads a configuration file. I'm able to open the file and load each line of it to each array position with the file command. However, now I need to analyse each line but could not find a way to read each field, like an awk equivelent.
The configuration file is like this:
GPIO; Direction; Active_low; Default_value; web_page; Description
1; out; 0; 0; yes; ficheiro1
2; out; 0; 0; yes; ficheiro2
My php script is this:
$conf=file('/etc/gpio.conf', FILE_SKIP_EMPTY_LINES);
for ($i=1; $i <3; $i++)
{
echo" conf $i: $conf[$i] <br />";
$GPIO=$1stfield_of_conf[i];
$Direction=$2ndfield_of_conf[i];
$Active_low=$3rdfield_of_conf[i];
}
What I would need would be something like awk '{print $1}', but capable of read a PHP array...
Any idea/suggestion?