I have php output like this:
data00,data01,data02,data03, , , and so on
data10,data11,data12,data13, , , and so on
data20,data21,data22,data23, , , and so on
(and so on in rows)
And this php code that generate this data.
<?php
$searchthis = $_GET["sea1"];
$matches = array();
$handle = @fopen("sources.csv", "r");
if ($handle)
{
while (!feof($handle))
{
$buffer = fgets($handle);
if(strpos($buffer, $searchthis) !== FALSE)
$matches[] = $buffer;
}
fclose($handle);
}
//show results:
print_r($matches);
Now I want to show a specific line on a specific column somewhere in the page and if I use:
<?php echo $matches[0]; ?>
it will show me the whole line, and not the specific data that i want. i can make something like this:
$output = echo $matches[0]
but then? how I should use the $output ?? for example if i need the second word instead of or the whole line.
now, after the the answer i update my files to looks like this: pls see if i am somewhere wrong, becouse is now not working.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type">
<title>my page</title>
</head>
<body>
<div style="text-align: center;">
<title>My Page</title>
<form name="myform" action="systemmonitor.php" method="GET">
<div align="center">My page<br>
<br>
<input name="sea1" placeholder="customtext" size="25" type="text"> <br>
<br>
<input name="sea2" placeholder="customtext" size="25" type="text"> <br>
<br>
<input name="sea" value="submit" type="submit"><br>
<br>
<?php
$searchthis = $_GET["sea1"];
$matches = array();
$handle = @fopen("systemlines.csv", "r");
if ($handle)
{
while (($buffer = fgetcsv($handle)) !== FALSE)
{
$check = preg_grep("/$searchthis/",$buffer);
if(!empty($check)){
$matches[] = $buffer;
}
}
fclose($handle);
}
//show results:
print_r($matches);?>
</body>
</html>
<?php echo $matches[0][4]; ?>