I am writing some script that read through a input file. My input file is using the "|" as a demlimiter. Each line of my input file should have 4 value that I would like to assign them to four variables.
For example line one, $Var1=CPU Summary, $Var2=7 Days, $Var3=CPU_Summary,$Var4=CPU_Summary.inc
Because I am not familiar with array not too sure how should I do it.
My Input File
CPU Summary|7 Days|CPU_Summary|CPU_Summary.inc
CPU Utilization Baseline|7 Days|CPU_Util_Base|CPU_Util_Base.inc
My Script
$myfile = input.txt;
$lines = file($myfile);
$data = array();
foreach ( $lines as $val ) {
$data[] = explode('|', $val);
}
for ($row = 0; $row < 2; $row++)
{
for ($column = 0; $column < 4; $column++)
{
echo $data[$row][$column];
}
}