Hi,
Where is my mistake? I have a function to grab filenames etcetc. and a function which will read the files, and parse the data in a variable, which is returned to the main program.
The variable $data gets filled fine in the function, but when it comes to the main program, the echo returns nothing.. What am I missing?
main program:
$numseries = sizeof($filenames);
$i = 0;
while ($i < $numseries)
{ // Start of seriesloop
$numfiles = sizeof($filenames[$i]);
$j = 0;
while ($j < $numfiles)
{
//echo $filenames[$i][$j] . "<br>";
$file = $location ."\\".$filenames[$i][$j];
$data = importdata($file, "GERascii");
echo $data[1][0]; //****this returns nothing, WHY NOT!?
$j++;
}
$i++;
}
Fileread routine:
function importdata($file, $type)
{
$cfile = $file;
$ctype = $type;
$fcontents = file( $cfile );
$lines = sizeof($fcontents);
switch($type)
{
case "GERascii":
echo"<b>";
echo $fname;
echo "</b><br>";
$i = 12;
while ($i < $lines)
{
$fcontents[$i] = ereg_replace(" {2,}", " ", $fcontents[$i]);
$data[$i] = explode(' ', $fcontents[$i]);
$data[$i][0] = 100*$data[$i][0]; //wavelength
//reference = data[1] ; radiance = data[2]
$data[$i][3] = 100*$data[$i][3]; //reflectance
//echo $data[$i][0];
$i++;
}
break;
}
return $data;
}