0
Hello,
I am trying to read the csv type files from a folder via script.
via browser it presents me the correct values of the array, but via CLI it presents me an empty array. Follow the code
$files = glob('*.csv');
var_dump($files);
Output via browser:
array(2) { [0]=> string(22) "Perdas\Score_Gauss.csv" [1]=> string(16) "Perdas\teste.csv" }
Output via CLI:
array(0){}
Any idea why this might be happening?
The code is correct, I would do otherwise but the code would be too big. Is the server you’re running on your machine? Maybe it lacks part of the directory path (PATH), a level above probably does not exist CSV files and therefore lists 0 arrays.
– RpgBoss
Man, I can’t believe it. Your question got me thinking why one works and the other doesn’t. It turns out that in the browser who manages the path is my IIS, ie I use the relative path, while in the CLI I need to use the full path ! How do I mark your answer as correct?
– Lessandro
Sorry, you can only evaluate comments (different from replies) when you have
reputação
necessary, yet I will put as an answer.– RpgBoss
I find it incredible how many people correct the text, but they don’t give an idea of how to solve the problem. A guy had the moral to correct removing the "Hello", as if this was decisive factor for the good understanding of the problem.
– Lessandro
Relax. I’m new here, too, but I understand that their level is to benefit the community. Making topics as standard as possible. They randomly review topics which gives them points as well. Now changing the subject. I hope my answer has solved your problem. If yes please mark it as the correct answer on the sign visa. Hug
– RpgBoss