我有一个PHP数组,其中管道dai,类和厚度,压力,OD,Id以三维方式合并。
现在我想匹配管道尺寸,然后选择压力和厚度
<?php
// Pipe Size, class, OD, ID, Thickness, Pressure.
$data = array(
“size 100”=>array(“K7” => array(112, 95, 4.5, 12.0),
(“K8” => array(112, 95, 3.5, 11.0),
(“K9” => array(112, 95, 2.5, 11.0)),
“size 150”=>array(“K7” => array(163, 145, 4.6, 10.0),
(“K8” => array(163, 145, 3.8, 13.0),
(“K9” => array(163, 145, 2.9, 15.0)),
“size 200”=>array(“K7” => array(210, 195, 5.5, 10.0),
(“K8” => array(210, 195, 4.1, 13.0),
(“K9” => array(210, 195, 3.5, 15.0))
);
当需要特定尺寸和尺寸时,我想要压力和厚度。 class由html表单提交。结果将按以下方式公布:
When the thickness is above: ($ans1) mm,
the Pressure would be: arraived: ($ans2) Mpa
HTML表格
<form method="post" name="data" action="data.php">
PIPE SIZE :
<select name="size" style="width: 100px" >
<option value="100">100 mmm
<option value="150"> 150 mm
<option value="200">200 mm
</select>
<br><br>
CLASS:
<select name="class" style="width: 100px" >
<option value="K7"> K7
<option value="K8"> K8
<option value="K9"> K9
</select>
<br><br>
<INPUT TYPE="button" VALUE="SUBMIT">
<input type="Reset" name="reset" value ="RESET" onClick ="(form);" />
</form>
答案 0 :(得分:0)
这应该有效:
<?php
$size_param = $_POST("size"); // like "size 100"
$class_param = $_POST("class"); // like "K7"
$pressure = $data[$size_param][$class_param][3];
$thickness = $data[$size_param][$class_param][2];
echo "When the thickness is above: ($size_param) mm,<br>the Pressure would be: arraived: ($pressure) Mpa";
?>
答案 1 :(得分:0)
这就是我要做的事情:
假设你有一个这样的数组(你的数组需要一些编辑)
$data = array(
"100" => array(
"K7" => array(112, 95, 4.5, 12.0),
"K8" => array(112, 95, 3.5, 11.0),
"K9" => array(112, 95, 2.5, 11.0)
),
"150" => array(
"K7" => array(163, 145, 4.6, 10.0),
"K8" => array(163, 145, 3.8, 13.0),
"K9" => array(163, 145, 2.9, 15.0)
),
"200" => array(
"K7" => array(210, 195, 5.5, 10.0),
"K8" => array(210, 195, 4.1, 13.0),
"K9" => array(210, 195, 3.5, 15.0)
)
);
然后查找这样的类和大小:
if ($_POST) {
$size = $_POST['size'];
$class = $_POST['class'];
$thickness = $data[$size][$class][2];
$pressure = $data[$size][$class][3];
echo "When the thickness is above: ($thickness) mm<br>";
echo "the Pressure would be: arraived: ($pressure) Mpa";
}
同时将submit input
从此<INPUT TYPE="button" VALUE="SUBMIT"
更改为此<input type="submit" value="submit">