> I have a series of commands like so (with different programs on each line):
> 
> display_pgm("bash");
> 
> Here is the bare bones of the function 'display_pgm':
> 
> function display_pgm ($pgm) {
> $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);
> }
> 
> If I can't get this part to work the rest of the function is a no-go. When I
> do this I get only one element in my array instead of the 3-4 I should be
> getting. I'm using bash for testing since I know that will always give a
> return.
> 
> I've also tried:
> eval("\$psArray = array(\"$ps2\");");
> and
> eval("\$psArray = array($ps2);"); - This one gives me a parse error
> (Parse error: parse error, unexpected T_STRING, expecting ')' in
> /var/www/html/ps.php(25) : eval()'d code on line 1)
> 
> When I have used the same eval in another page I get each part separated by
> the comma as a separate element in the array. What in the world am I doing
> wrong?

For $psArray to be an array, shouldn't it be:

eval("\$psArray[] = array(\$ps2);");

--
Lowell Allen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to