【发布时间】:2018-09-21 06:28:50
【问题描述】:
如果我有一个多维数组,我怎样才能使数组中的某些组(例如:'wages'、'hrs')被插入到某个公式中变成 $x,这样它就可以去通过下面的 ifelse 语句?
我正在使用这个通用函数计算月薪:
($employees[0]['wage']) * ($employees[0]['hrs']) * 4
但是,我想知道如何格式化第一个括号(键?)$employees[ _ ],以便“hrs”和“wage”值下的数组的每个值都可以计算出每个员工的 $x数组(有 9 个)。我假设我会创建一个循环,但我将如何填写括号以实现这一点?
with monthly salary = ($employees[_]['wage']) * ($employees[_]['hrs']) * 4
where $employees is a pre-set multidimensional array I created.
<?php
$x = __
if ( $x >= 3000 ) {
echo "High paying";
} elseif ( 2000 =< x =< 2999 ) {
echo "Good paying";
} else {
echo "Low paying";
}
?>
【问题讨论】:
标签: php arrays loops if-statement