WD68AA
400
file.jpg
2
The plist.php file at the moment reads in house.txt and displays the file as it is below.The getValue.php is a function that i would like to use to display the txt file as it is above....im stuck on as to how to put them together to do this??
So that plist.php reads the txt file and getValue.php sorts the file using the explode() function?
Thankyou in advance,
[text]
#house.txt
WD68AA,400,file1.jpg,2
SL29DD,350,house8.jpg,4
WM34SA,180,flat2.jpg,5
SK22MW,220,house5.jpg,3
KS23RR,260,flat6.jpg,2
[/text]
#Plist.php
Code: Select all
<?
$filename = "house.txt";
$filepointer = fopen($filename,"r"); // open for read
$myarray = file ($filename);
for ($mycount = 0; $mycount < count($myarray); $mycount++ )
{
// one input line at a time
$aline = $myarray[$mycount];
print $aline ."\n <br>";
}
fclose ($filepointer);
#if (!($filepointer = fopen($filename,"r"))){ exit;
}
?>
Code: Select all
<?
$details = "hello,aa,bb,cc,dd,ee,there";
$partdetails = &getvalue($details,3);
print " $details then $partdetails ";
exit; #finish here - so it does not run into function accidentally
function getvalue ($text, $commaToLookFor)
{
$intoarray = explode(",",$text);
return $intoarray[ $commaToLookFor];
}
?>