Re: returning array from commandline
| From: | Ian | Date: | Fri, 10 Oct 2008 13:56:43 +0000 |
| Subject: | Re: returning array from commandline | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281666@lists.php.net to get a copy of this message | ||
On Fri, Oct 10, 2008 at 3:47 PM, Per Jessen <per@computer.org> wrote:
> 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.
>
Yep, my bad - thats bad english - it was talking about the output that
the commandline tool spews out - i was hoping to return the entire
array for use within the web interface.
>> 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.
Thats what i suspected - was just taking a gamble that someone would
have an ideal solution and make my life much easier :) ill have to
manually add some switch cases for different result sets and then a
decompile function on the other end.
>
>> 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?
I have to use it as I cant include some required files into my web ui
as they interfere with the base system (not one i wrote) and it causes
all sorts of havoc so I have resorted to creating a "bridge" to
combine the two systems which is where this problem comes in.
Many thanks :)
>
>
> /Per Jessen, Zürich
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>