note 127233 deleted from function.file by cmb
| From: | cmb@php.net | Date: | Thu, 07 Jul 2022 10:07:00 +0000 |
| Subject: | note 127233 deleted from function.file by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218918@lists.php.net to get a copy of this message | ||
Note Submitter: max dot bohrmann at gmx dot net
----
<?php
/*------------------M A I N----------------------------*/
$data="logSkipass.txt";
$pass="00788";
if(getLiftLength($data,$pass)==-1){exit("<p>Datei nicht gefunden.</p>");}
echo "<p>Der Benutzer mit der PassID: ".$pass." hat insgesamt :
".getLiftLength($data,$pass)." m Liftstrecke benutzt</p>";
/* ---------------F U N C T I O N S--------------------*/
function getLiftLength($dataName,$passID):int
{
$liftLength=0;
if(!file_exists($dataName))
{
return -1;
}
else
{
$fp=fopen($dataName,"r");
while(!feof($fp))
{
$row=fgets($fp);
$rowArray=explode("|",$row);
//var_dump($rowArray);
//echo $rowArray[2]." --> ".$rowArray[5]."<br>";
if($rowArray[2]==$passID)
{
$liftLength+=(int)$rowArray[5]; //Typecast
}
}
fclose($fp);
return $liftLength;
}
}
?>