Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: curl_setopt_array gives notice "array to string conversion"

Tags:

php

curl

curl_setopt_array( $ch, $curl_opt );

This code gives a Notice Notice: Array to string conversion in ...

This is what $curl_opt contains:

array (size=5)
  42 => boolean true
  19913 => boolean true
  10018 => string 'PHP RestClient/0.1.2' (length=20)
  10005 => 
    array (size=1)
      0 => string 'user:password' (length=13)
  10002 => string 'http://longurl.com/' (length=389)

is_array($curl_opt) returns true, so I don't really know what's causing the notice.

I think I'm just missing something really simple here but I just cannot, for the life of me, figure this one out.

It's just a notice and doesn't break anything but it just annoys me that I don't know what's causing it.

like image 630
rgin Avatar asked Apr 14 '14 04:04

rgin


People also ask

What is cURL_ setopt in PHP?

curl_setopt — Set an option for a cURL transfer.


1 Answers

$curl_opt should be a one-dimensional array................................

The key 10005 is not that case, it should be

$curl_opt = array(
  //...
  CURLOPT_USERPWD => '[username]:[password]'
  //...
);
like image 141
xdazz Avatar answered Oct 16 '22 02:10

xdazz