Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18879 > unrolled thread

directing curl output to an array or string

Started bybill <william@TechServSys.com>
First post2022-03-10 15:19 -0500
Last post2022-03-12 07:33 -0500
Articles 6 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  directing curl output to an array or string bill <william@TechServSys.com> - 2022-03-10 15:19 -0500
    Re: directing curl output to an array or string Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-03-10 20:30 +0000
      Re: directing curl output to an array or string Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-03-10 20:44 +0000
        Re: directing curl output to an array or string bill <william@TechServSys.com> - 2022-03-10 19:26 -0500
          Re: directing curl output to an array or string Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-03-11 01:24 +0000
            Re: directing curl output to an array or string bill <william@TechServSys.com> - 2022-03-12 07:33 -0500

#18879 — directing curl output to an array or string

Frombill <william@TechServSys.com>
Date2022-03-10 15:19 -0500
Subjectdirecting curl output to an array or string
Message-ID<t0dmg7$1o6j$1@gioia.aioe.org>
I would like to direct curl output to a string or an array.

I see how I can direct it to a file and then I could read it back 
in to a variable, but it seems there should be a way to just read 
the output to a string or array.

Thank you in advance.

-bill

[toc] | [next] | [standalone]


#18880

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2022-03-10 20:30 +0000
Message-ID<t0dn5p$cbl$1@dont-email.me>
In reply to#18879
On Thu, 10 Mar 2022 15:19:19 -0500, bill wrote:

> I would like to direct curl output to a string or an array.

See the first example on
  https://www.php.net/manual/en/curl.examples.php

> I see how I can direct it to a file and then I could read it back 
> in to a variable, but it seems there should be a way to just read 
> the output to a string or array.

HTH
-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#18881

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2022-03-10 20:44 +0000
Message-ID<t0dnug$cbl$2@dont-email.me>
In reply to#18880
On Thu, 10 Mar 2022 20:30:49 +0000, Lew Pitcher wrote:

> On Thu, 10 Mar 2022 15:19:19 -0500, bill wrote:
> 
>> I would like to direct curl output to a string or an array.
> 
> See the first example on
>   https://www.php.net/manual/en/curl.examples.php

or, did you mean something like

<?php
  exec("curl http://google.com/",$OUTPUT,$RC);
  echo $OUTPUT;
?>



-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#18882

Frombill <william@TechServSys.com>
Date2022-03-10 19:26 -0500
Message-ID<t0e508$18ib$1@gioia.aioe.org>
In reply to#18881
On 3/10/2022 3:44 PM, Lew Pitcher wrote:
> On Thu, 10 Mar 2022 20:30:49 +0000, Lew Pitcher wrote:
> 
>> On Thu, 10 Mar 2022 15:19:19 -0500, bill wrote:
>>
>>> I would like to direct curl output to a string or an array.
>>
>> See the first example on
>>    https://www.php.net/manual/en/curl.examples.php
> 
> or, did you mean something like
> 
> <?php
>    exec("curl http://google.com/",$OUTPUT,$RC);
>    echo $OUTPUT;
> ?>
> 
> 
> 
Thanks Lew.
-bill

[toc] | [prev] | [next] | [standalone]


#18883

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2022-03-11 01:24 +0000
Message-ID<t0e8bh$cbl$3@dont-email.me>
In reply to#18882
On Thu, 10 Mar 2022 19:26:48 -0500, bill wrote:

> On 3/10/2022 3:44 PM, Lew Pitcher wrote:
>> On Thu, 10 Mar 2022 20:30:49 +0000, Lew Pitcher wrote:
>> 
>>> On Thu, 10 Mar 2022 15:19:19 -0500, bill wrote:
>>>
>>>> I would like to direct curl output to a string or an array.
>>>
>>> See the first example on
>>>    https://www.php.net/manual/en/curl.examples.php
>> 
>> or, did you mean something like
>> 
>> <?php
>>    exec("curl http://google.com/",$OUTPUT,$RC);
>>    echo $OUTPUT;
>> ?>

To answer the question you asked me offline

> Please explain the "something like"

while PHP has a built-in cURL interface (in the curl_* functions),
you can also use the php exec() function to execute the standalone
curl command.

https://www.php.net/manual/en/function.exec.php
explains the parameters to this function.

The array (that I named $OUTPUT) will contain the data returned
by the curl command, satisfying your quest to "direct curl output
to ... an array".

The argument that I named $RC will contain the return status of the
curl command.


> Thanks Lew.
> -bill

You are very welcome.

Luck be with you
-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#18884

Frombill <william@TechServSys.com>
Date2022-03-12 07:33 -0500
Message-ID<t0i3vd$1jvm$1@gioia.aioe.org>
In reply to#18883
On 3/10/2022 8:24 PM, Lew Pitcher wrote:
> On Thu, 10 Mar 2022 19:26:48 -0500, bill wrote:
> 
>> On 3/10/2022 3:44 PM, Lew Pitcher wrote:
>>> On Thu, 10 Mar 2022 20:30:49 +0000, Lew Pitcher wrote:
>>>
>>>> On Thu, 10 Mar 2022 15:19:19 -0500, bill wrote:
>>>>
>>>>> I would like to direct curl output to a string or an array.
>>>>
>>>> See the first example on
>>>>     https://www.php.net/manual/en/curl.examples.php
>>>
>>> or, did you mean something like
>>>
>>> <?php
>>>     exec("curl http://google.com/",$OUTPUT,$RC);
>>>     echo $OUTPUT;
>>> ?>
> 
> To answer the question you asked me offline
> 
>> Please explain the "something like"
> 
> while PHP has a built-in cURL interface (in the curl_* functions),
> you can also use the php exec() function to execute the standalone
> curl command.
> 
> https://www.php.net/manual/en/function.exec.php
> explains the parameters to this function.
> 
> The array (that I named $OUTPUT) will contain the data returned
> by the curl command, satisfying your quest to "direct curl output
> to ... an array".
> 
> The argument that I named $RC will contain the return status of the
> curl command.
> 
> 
>> Thanks Lew.
>> -bill
> 
> You are very welcome.
> 
> Luck be with you

Thanks again Lew and apologies for contacting  you directly.  I 
hit the wrong reply button.
-bill

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web