我有一个数组:
$TaxIds=array(2) { [0]=> string(1) "5" [1]=> string(2) "10" }
Run Code Online (Sandbox Code Playgroud)
我需要转换为:
$TaxIds=array(2) { [0]=> int(5) [1]=> int(10) }
Run Code Online (Sandbox Code Playgroud)
简单的方法???
小智 12
@george 答案的简化版本是:
$TaxIds = array_map('intval', $TaxIds);
Run Code Online (Sandbox Code Playgroud)
更多信息请访问array_map
虽然这个问题很久以前就被问过了,但它可能对某人有用
您可以使用array_map
$TaxIds = array_map(function($value) {
return intval($value);
}, $TaxIds);
Run Code Online (Sandbox Code Playgroud)