【问题标题】:PHP retrieve information from arrayPHP从数组中检索信息
【发布时间】:2022-01-08 18:01:10
【问题描述】:

我需要从数组中获取值。

我的代码:

$tags = $array['bePVM'][''];
echo ('<form action="" method="POST">');
for($o = 0; $o<$i; $o++){
   echo "<br>Užsakymo: <b> ",$data2DArray[$o][0], "</b> Price witout VAT: ",'<input type="text" name="bePVM[]" value="">'," VAT: ",'<input type="text" name="PVM[]" value="">'," Price with VAT: ",'<input type="text" name="suPVM[]" value="">',"<br>";
}
echo ('<input type="submit" value="">');
echo ('</form>');
print_r($_POST);
    echo $tags[1];

我有这个输出:

Warning: Trying to access array offset on value of type null


Array ( [bePVM] => Array ( [0] => 100 
                           [1] => 200 ) 
          [PVM] => Array ( [0] => 21 
                           [1] => 42  ) 
        [suPVM] => Array ( [0] => 121 
                           [1] => 242 ) 
      )

我如何回显 [bePVM][1] 哪里是 200?

谢谢

【问题讨论】:

  • 你已经声明了标签$tags = $array['bePVM'][''];并且你正在打印echo $tags[1];,这将显示array offset on value of type null

标签: php multidimensional-array


【解决方案1】:

我如何回显 [bePVM][1] 哪里是 200?

如果输出来自print_r($_POST);,那么这应该将200 写入输出:

echo $_POST['bePVM'][1];

【讨论】:

    猜你喜欢
    • 2013-07-17
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 1970-01-01
    相关资源
    最近更新 更多