【发布时间】:2021-12-15 00:58:33
【问题描述】:
我有一个数组集合,我使用 toArray() 将其转换为数组。它将所有项目更改为字符串。我想检查每个可以转换为整数/小数的项目。数组是这样的
['first_name'] => 'Jake',
['last_name'] => 'Doe',
['age'] => '13', (Change this to an integer/decimal)
['address'] => 'Ivory Street'
['allowance'] => '3000' (Change this to an integer/decimal)
我正在使用 Laravel/Livewire
【问题讨论】:
-
这能回答你的问题吗? Checking if a variable is an integer in PHP
-
你可以使用模型铸造