0

I have a script which gathers information from a linux command and then splits the string into an array

Problem is once the command gathers loads of lines the explode function just stops working

$fetch = shell_exec('BIGLISTOFNEWLINESPERATEDDATA');

$fetcharray = explode("\n", $fetch);

I have also tried-

$fetcharray = explode("\n", $fetch,-1);

and

$fetcharray = preg_split("\n", $fetch);

But they all have the same issue - I know that the string command itself is fine because I can output it as a string no matter what the length...

Brick
  • 101
  • 1
  • 8
  • Say you exploded, what are the next steps? – nice_dev Mar 24 '21 at 18:35
  • It's unclear what "stops working" means exactly? Do you get an error? – ADyson Mar 24 '21 at 18:35
  • the page doesn't render anything after the line that contains the explode command - it just stops dead – Brick Mar 24 '21 at 18:43
  • FYI: IT works with approx 590402 values, ( i cant get the exact figure) – Brick Mar 24 '21 at 18:48
  • Might be a case of a loop, find the next new line and extract the first part, repeat until all of the string is processed. – Nigel Ren Mar 24 '21 at 18:51
  • The next steps are that it runs though the array of values and manipulates the data into a different format and then feeds them back into another command + outputs a selection of the values into a html table – Brick Mar 24 '21 at 18:51

1 Answers1

0

I figured it out, php was hitting its maximum memory size.

I upped that in php.ini and now it can reder much more data.

Paolo
  • 20,112
  • 21
  • 72
  • 113
Brick
  • 101
  • 1
  • 8