2016-09-22 5 views
-3

カールでネストされた配列を渡したいと思います。私は、これはエラーMSGでしようとすると、私はネストされた配列をカールで渡す方法

"(!) Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in line 39"

を得るitmean「=>」この構文は、私はそれがまた動作していないうち括弧で試す

間違っています。この配列をどうやって渡すことができますか?

$baseurl = 'http://202.124.173.187/api/v1/payConfirm';  
    $rawPOSTdata = array 


     (
     "deviceCode"=>"", 
     "applicationId"=>"", 

    "patient",(



       "member"=>"", 
       "needSMS"=>"true", 
       "nsr"=>"", 
       "foreign"=>"", 
       "teleNo"=>"0777136419", 
       "title"=>"mrs", 
       "patientName"=>"sufra", 
       "nid"=>"887111596v", 

     ) 
    "sessionDetails", 
       (
       "hosId"=>"H138", 
       "docId"=>"D3648", 
       "theDay"=>"Monday", 
       "startTime"=>"13:00", 
       "theDate"=>"03-10-2016", 

) 



     "payment", 

        (
         "paymentMode"=>"EPG", 
         "bankCode"=>"", 
         "branchCaode"=>"M000444", 
         "paymentChannel"=>"WEB_PO", 
         "channelFrom"=>"W", 
        ) 

       ); 

$curl = curl_init($baseurl); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-type: multipart/form-data',"Authorization: Bearer $atoken")); 
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($rawPOSTdata)); 

$response = curl_exec($curl); 
curl_close($curl); 

if($response) 
    { 
     if (isset($result->error))die($result->error_message); 
     /* Convert json data to array */ 

     $arr=json_decode($response,true); 

    echo '<pre>';echo print_r ($arr); echo '</pre>'; 
+0

あなたの配列をコードします。 – aldrin27

+0

"patient" =>配列( – CatalinB

+0

) "sessionDetails" is)、 "sessionDetails" =>配列( ' – CatalinB

答えて

0

使用この配列は、ネストされたアレイは、再びアレイ約

$rawPOSTdata = array(
    "deviceCode"=>"", 
    "applicationId"=>"", 
    "patient" => array(
    "member"=>"", 
    "needSMS"=>"true", 
    "nsr"=>"", 
    "foreign"=>"", 
    "teleNo"=>"0777136419", 
    "title"=>"mrs", 
    "patientName"=>"sufra", 
    "nid"=>"887111596v", 
), 
    "sessionDetails" => array(
    "hosId"=>"H138", 
    "docId"=>"D3648", 
    "theDay"=>"Monday", 
    "startTime"=>"13:00", 
    "theDate"=>"03-10-2016", 
), 
    "payment" => array(
    "paymentMode"=>"EPG", 
    "bankCode"=>"", 
    "branchCaode"=>"M000444", 
    "paymentChannel"=>"WEB_PO", 
    "channelFrom"=>"W", 
), 
); 

より以下のようにアレイとして()を書かなければならない - http://php.net/manual/en/language.types.array.php

+0

@kanzulこれで問題は解決しますか? – jitendrapurohit

関連する問題