我有以下计算:
$this->count = float(44.28)
$multiple = float(0.36)
$calc = $this->count / $multiple;
$calc = 44.28 / 0.36 = 123
Run Code Online (Sandbox Code Playgroud)
现在我想检查我的变量$calc是否是整数(有小数).
我尝试过,if(is_int()) {}但这不起作用,因为$calc = (float)123.
也试过这个 -
if($calc == round($calc))
{
die('is integer');
}
else
{
die('is float);
}
Run Code Online (Sandbox Code Playgroud)
但这也行不通,因为它在每种情况下都会返回'is float'.在上面的情况下,这应该是真的,因为在舍入后123与123相同.
您好我想将单个数组的值放入一个多维数组中,每个值都在n + 1上这是我的数组$结构
Array
(
[0] => S
[1] => S.1
[2] => S-VLA-S
[3] => SB
[4] => SB50
)
Run Code Online (Sandbox Code Playgroud)
我想输出的是这个
Array
(
[S] => Array(
[S.1] => Array (
[S-VLA-S] => Array (
[SB] => Array (
[SB50] => Array(
'more_attributes' => true
)
)
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所尝试的
$structures = explode("\\", $row['structuurCode']);
foreach($structures as $index => $structure) {
$result[$structure][$structure[$index+1]] = $row['structuurCode'];
}
Run Code Online (Sandbox Code Playgroud)
数组的值是树结构,这就是为什么将它们放在多维数组中会很方便的原因
提前致谢.
我正在阅读一个带有php的excell文件.没问题,但我被困在一个小逻辑部分.我想创建一个包含数据的多个其他数组的数组.
数据在我的excell文件中提供,我从哪个列开始读取但不知道何时停止,因为这是动态的.
我的问题是如何创建一个循环来读取我的列并在每个第5列上创建一个新数组.
所以我想要的是这样的:
(My data for the excell file is proved in $line[] each column has its number.)
array(
'length' => $line[15],
'width' => $line[16]
'price_per' => $line[17],
'price' => $line[18],
'stock' => $line[19]
),
array(
'length' => $line[20],
'width' => $line[21]
'price_per' => $line[22],
'price' => $line[23],
'stock' => $line[24]
),
array(
'length' => $line[25],
'width' => $line[26]
'price_per' => $line[27],
'price' => $line[28],
'stock' => $line[29]
), ....
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能使这个动态(for循环?)这样我有一个大的索引数组,有多个相关联的数组?注意:我的for循环应始终从第[15]行加注星标!