From: "Susan Ator" <[EMAIL PROTECTED]> > For example, the command: > > ps -C bash --no-headers -o fname,state,vsz,start_time,flag,user,cputime,args > --cols 200 > > gives me the output of: > bash S 4396 Nov13 000 sator 00:00:00 -bash > bash S 4392 Nov13 000 sator 00:00:00 -bash > bash S 4396 Nov13 000 sator 00:00:00 -bash > > The array I end up with using this code (where $pgm is bash): > > $cmd = " -C $pgm --no-headers -o > pid,fname,state,vsz,start_time,flag,user,cputime,args --cols 200"; > $ps = `ps $cmd`; > $ps2 = ereg_replace("\n", ",", $ps); > eval("\$psArray = array(\$ps2);"); > print_r($psArray); > > is: > > Array ( [0] => bash sleeping 4396 Nov13 000 sator 00:00:00 -bash,bash > sleeping 4392 Nov13 000 sator 00:00:00 -bash,bash sleeping 4396 Nov13 000 > sator 00:00:00 -bash ) > > where I need it to be: > > Array ( > [0] => bash S 4396 Nov13 000 sator 00:00:00 -bash > [1] => bash S 4392 Nov13 000 sator 00:00:00 -bash > [2] => bash S 4396 Nov13 000 sator 00:00:00 -bash > ) > > and the second array needs to be: > > Array ( > [0] => Array ( > [0] => bash > [1] => S > [2] => 4396 > [3] => Nov13 > [4] => 000 > [5] => sator > [6] => 00:00:00 > [7] => -bash > ) > etc... > ) > > THIS is what I am unable to do. Does anyone have any ideas?
$Array1 = array(); $Array2 = array(); $cmd = " -C $pgm --no-headers -o pid,fname,state,vsz,start_time,flag,user,cputime,args --cols 200"; $ps = `ps $cmd`; $Array1 = explode("\n",$ps); foreach($Array1 as $line) { $Array2[] = explode(" ",$line); } print_r($Array1); print_r($Array2); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php