两个数组乘法名称x [重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

输入名称“选项[] [宽度]”因为我想要2输入乘法,但它不会崩溃。输入名称请。

<?php 
    $height = null; 
    $width = null; 
    function vir2nok($data) { 
        return str_replace(",",".",$data); 
    } 
    if ($_POST) { 
        $height = vir2nok($_POST["height"]); 
        $width = vir2nok($_POST["width"]); 
        if (is_numeric($height) && is_numeric($width)) { 
            $sonuc = $height * $width; 
            echo $height." x ".$width." = ".$sonuc."<hr>"; 
        } 
    } 
?> 


<form action="" method="post"> 

<input type="text" name="option[<?php echo $option['product_option_id']; ?>][height]"  placeholder="<?php echo $label_height; ?>" id="input-option<?php echo $option['product_option_id']; ?>" class="pso-height-input form-control" />
<input type="text" name="option[<?php echo $option['product_option_id']; ?>][width]"  placeholder="<?php echo $label_width; ?>" id="input-option<?php echo $option['product_option_id']; ?>" class="pso-width-input form-control" />

 <input type="submit" name="gonder"> 
</form>
php jquery html css html5
1个回答
0
投票

您没有正确访问字段,尝试将这两行更改为:

$height = vir2nok($_POST["option"][$option['product_option_id']]["height"]); 
$width = vir2nok($_POST["option"][$option['product_option_id']]["width"]);
© www.soinside.com 2019 - 2024. All rights reserved.