Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.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 - Fatal编程技术网

Php 如何从表单转发器读取发布的数组

Php 如何从表单转发器读取发布的数组,php,Php,如何从表单转发器读取发布的数组 最好的是从表单帖子获得的数组 Array ( [products] => Array ( [0] => Array ( [pid] => 1 [qty] => 2 ) [1] => Array ( [pid] => 1 [qty] => 2

如何从表单转发器读取发布的数组

最好的是从表单帖子获得的数组

Array ( 
    [products] => Array ( 
        [0] => Array ( 
            [pid] => 1 
            [qty] => 2 
        ) 
        [1] => Array ( 
            [pid] => 1 
            [qty] => 2 
        ) 
        [2] => Array ( 
            [pid] => 1 
            [qty] => 2 
        ) 
    ) 
)
我的问题是如何解读这样的价值观:

$pid[1]=1


$qty[1]=1

您可以像这样访问数组值

<?php
    $array = array("products"=> [["pid" => 1 , "qty" => 2 ],
                                 ["pid" => 2 , "qty" => 3 ],
                                 ["pid" => 3 , "qty" => 4 ]]);
    echo "PId: " . $array["products"][0]["pid"] . "<br>";
    echo "qty: " . $array["products"][0]["qty"] . "<br><br>";
    print_r($array);
    ?>


查看PHP小提琴的工作

您可以像这样访问数组值

<?php
    $array = array("products"=> [["pid" => 1 , "qty" => 2 ],
                                 ["pid" => 2 , "qty" => 3 ],
                                 ["pid" => 3 , "qty" => 4 ]]);
    echo "PId: " . $array["products"][0]["pid"] . "<br>";
    echo "qty: " . $array["products"][0]["qty"] . "<br><br>";
    print_r($array);
    ?>


查看PHP提琴以了解工作情况

$thePid=$arr['products'][0]['pid']您需要使用$products=$\u POST['products'];echo$products[0]['pid']@RiggsFolly——谢谢你的指导,但什么都不起作用。@Girish Sasidharan——谢谢你的指导,但没有起作用。什么都不起作用,但你接受的答案完全是我所做的
$thePid=$arr['products'][0]['pid']您需要使用$products=$\u POST['products'];echo$products[0]['pid']@RiggsFolly——谢谢你的指导,但没什么用。@Girish Sasidharan——谢谢你的指导,但没什么用。没什么用,但你接受了一个回答,上面说的正是我所做的``echo$_POST[“products”][0][“pid”];```````echo$_POST[“产品”][0][“pid”]```