如何使用PHP在REST中将数组作为post请求发送?

Here is my code,

$ip = array([0]=>'1.1.1.1' [1]=> '2.2.2.2')

$ux = RestClient::post($url,array('requestType'=>'Ip', 
                                                     'username' => 'user', 
                                                             'pass' =>'user',
                        'type'=>$type,
                        'ip'=>array($ip)                            
                            ));
  echo $ux->getResponse();

How to post 'ip' at server side? When I use $_POST['id'], it returns 'Array' as string.

You can't post an array. You have to serialize it to a string. That could be the standard form encoding method:

ip=1.1.1.1&ip=2.2.2.2

That could be JSON:

{ "ip" : [ "1.1.1.1", "2.2.2.2" ] }

That could be some XML format:

<ips>
    <ip>1.1.1.1</ip>
    <ip>2.2.2.2</ip>
</ips>

That could be something else.

… but what you need to do depends on what the API you are submitting to expects.

I suspect you need to use JSON for your array. Convert it with json_encode( $array )