array_combine();没有正确地产生价值

时间:2016-10-11 17:39:19

标签: php html arrays session

编辑:好吧,我原来的帖子有点令人困惑,我也尝试了一些新的东西。这是我的代码:

if($_POST['submit']=='Save'){
    $_SESSION['quantity'] = $_POST['quantity'];

    $_SESSION['order'] = array_combine($_SESSION['parts-order'], $_SESSION['quantity']);

   header("Location: shopping.php");
    exit;
}

两个$ _SESSION数组都是430长,都包含字符串。当我分别在两个$ _SESSION数组上print_r()时,它们返回它们的预期值。基本上,当我组合数组时,我期望这个输出:

Array
(
    [1 inch ratchet tie down] => 13
    [24" White Ring Buoy w/ Reflective Tape] => 4
    [50' Throw Line w/bag] => 5
    [Classic Shirt Large] => 0
    ...
)

Y'知道,或者$ _SESSION ['数量']中的任何值。相反,我得到了这个:

Array
(
    [1 inch ratchet tie down] => 0
    [24" White Ring Buoy w/ Reflective Tape] => 0
    [50' Throw Line w/bag] => 0
    [Classic Shirt Large] => 0
    ...
)

除非每个$ _SESSION ['数量']值相同,否则它会产生0.如何在array_combine的过程中将值更改为0?

感谢。

0 个答案:

没有答案