Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 命令行数据转换为数组_Php_Arrays_Curl - Fatal编程技术网

Php 命令行数据转换为数组

Php 命令行数据转换为数组,php,arrays,curl,Php,Arrays,Curl,我有一个curl摄像机,但我不知道我是否有一个正确的数据代码,我把它转换成数组。我对curl代码没有问题,我已经测试了curl cammand,但我只想澄清一下我是否有正确的数据语法 命令行 curl - v - H "Accept: application/json" - H "Content-type: application/json" - X POST - d '{"cart" : {"cancel_url":"http://yourdomain.com/your_ca

我有一个curl摄像机,但我不知道我是否有一个正确的数据代码,我把它转换成数组。我对curl代码没有问题,我已经测试了curl cammand,但我只想澄清一下我是否有正确的数据语法

命令行

curl - v 
- H "Accept: application/json" 
- H "Content-type: application/json" 
- X POST 
- d '{"cart" : 
    {"cancel_url":"http://yourdomain.com/your_cancel_url",
        "invoice":"11111111",
        "notes":"sample note",
        "success_url":"http://yourdomain.com/your_success_url",
        "total_amount":"30.0",
        "total_quantity":"12.0",
        "items_attributes":
            [
                {"item_code":"111111111-aaa",
                "item_name":"aaaaaaaa",
                "notes": "test item note",
                "price":"2.5", 
                "quantity":"12.0", 
                "amount":"30.0"}
             ]
       }
    }'
这是我转换为数组的数据命令行,我添加了更多项。 请参见命令行中的items\u属性,其中有[]。[]这意味着客户端可以添加多个项目,对吗

$data = array(
    'cart' => array(
        'cancel_url' => "www.google.com",
        'invoice' => '1111111',
        'notes' => 'hello world',
        'success_url' => "www.yahoo.com",
        'total_amount' => 20.00,
        'total_quantity' => 2,
        'item_attributes' => array( 
            array(
                'item_code' => "11111-aaa",
                'item_name' => 'bogart',
                'notes' => 'first notes',
                'price' => 15.2,
                'quantity' => 2,
                'amount' => 20.00
            ),
             array(
                'item_code' => "11111-aaa",
                'item_name' => 'bogart2',
                'notes' => 'second notes',
                'price' => 15.2,
                'quantity' => 2,
                'amount' => 20.00
            )
        )
    )
);

我是新来的。请帮帮我

是的,这意味着它可以有多个值。这是你唯一的问题吗?@丹:是的!谢谢你,伙计。我试图阅读该教程,但找不到任何确切的资源。您是否喜欢此项目属性:[{item_代码:111111111-aaa,item_名称:aaaaaaaa,备注:测试项目备注,价格:2.5,数量:12.0,金额:30.0},{项目代码:111111111-aaa,项目名称:aaaaaaaa,备注:测试项目备注,价格:2.5,数量:12.0,金额:30.0}]@SamarHaider否。我的意思是,我的数据有正确的语法吗?如果我在我的项目属性中添加更多的项目。对于添加更多项目属性$data['cart']['item\u attributes'][]=数组'item_code'=>11111-aaa,'item_name'=>'bogart2','notes'=>'second notes','price'=>15.2','quantity'=>2','amount'=>20.00;