假设在对数组应用implode之后,我得到一个String例如: -
$ var = 1631075,1631076;
在将var_dump应用于$ var时,我收到输出为字符串(15)" 1631075,1631076"
如何将整个$ var转换为Integer变量。这样var_dump显示int(15)1631075,1631076
答案 0 :(得分:0)
$var = '1631075,1631076';
foreach(explode(',',$var) as $val){
echo intval($val);
}
或类似
$var = '1631075,1631076';
$integers = explode(',',$var);
$converted = array_map('intval', $integers);