I have a PHP script that returns an array of numbers:
$fh = fopen ("./files/".$file, r);
$filedata= explode('|', fgets($fh));
echo $filedata[5];
result:
0.23387718200684
3.6163940429688
0.030826568603516
Is there a way to get the script to return results added up as just one number?
As I see in your code, you are executing it in command line and you do echo $filedata[5] an you get different lines, this is because you are not paying attention to ‘\n’ character, so what you need is to change that character somehow…
there are different ways… In this example I’m changing the “\n” for ” ” simple space