php - Saving console application output in an array directly -


how can further comparision or computation on output of console application. believe in ascii form. have called console application in php gives huge amount of numeric datas. want data saved on array , not in txt file process of reading , writing file takes time want directly save in array. used exec($command,$result) cannot result saved in proper form. output shown below:

    columns 1 through 7  0.1373    0.0414    0.0541    0.1342    0.5606    0.5293    0.1652   columns 8 through 14  0.0341    0.0396    0.0633    0.0778    0.0289    0.0654    0.0752  columns 15 through 21  0.3055    0.4602    0.0631    0.0360    0.0188    0.0497    0.0228........... 

i dont want columns line saved in array , want each element in column saved in different index of array. eg array[1]=0.1373 , array [2]=0.414.

my suggestion simple regular expression run on each line of output:

if (preg_match_all('/\d+\.\d+/', $line, $matches)) {     print_r($matches[0]); } 

if expression matches, have array of results can use further processing. output first line matches post:

array (     [0] => 0.1373     [1] => 0.0414     [2] => 0.0541     [3] => 0.1342     [4] => 0.5606     [5] => 0.5293     [6] => 0.1652 ) 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -