<?php
$flag ='';
$searchthis = $_GET["searchthis"];
$items = array('Release:', 'Kernel:', 'Network:', 'CPU:', 'Memory:', 'Disk:', 'Packages:');
$hostname = $_GET["hostname"];
$file = new SplFileObject($hostname."_inventory.txt");
$i=1;
echo $file;
$lines = file($file);
The intended goal here is to read each line of file object $file into an array so i can loop through it. When I run the above code, the result is always the first string in the items array over and over and over again ie. Release:Release:Release:Release: etc..
Use file
array properly.
$flag ='';
$searchthis = $_GET["searchthis"];
$items = array('Release:', 'Kernel:', 'Network:', 'CPU:', 'Memory:', 'Disk:', 'Packages:');
$hostname = $_GET["hostname"];
$file = new SplFileObject($hostname."_inventory.txt");
foreach($file as $fl){
echo $fl.'PHP_EOL';
}