Re: returning array from commandline

From: Date: Fri, 10 Oct 2008 13:47:05 +0000
Subject: Re: returning array from commandline
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-281665@lists.php.net to get a copy of this message
Ian wrote: > I am busy developing a commandline tool that will, in certain > cirumstances, return an array of information when called and im having > a problem with this. Ian, that's a bit of a contradiction - a command line tool returns a return code. > The last part of my code looks like this: > > if(is_array($rslt)) return $rslt; > else echo $rslt; > > I.e. if its an array dont echo it, return it rather and im have huge > problems even using that $rslt variable. I have tried various exec > queries including exec() (with var before function call and as a > parameter), passthru, backtick operators and none of them allow me to > use the array after the commandline tool has been run. Exactly - the array is a PHP construct, once you've called the command script, you've moved into your basic OS environment - which doesn't understand about PHP arrays. > Quick summary: Im accessing a web interface that calls a php file to > parse some info. That php file may get an array back that I need to > use in the web interface - but I cant pass it back to the web > interface from the commandline tool. Why does it have to be called as a command line tool? Why not just call it as a plain PHP function? /Per Jessen, Zürich

« previous php.general (#281665) next »