开发者

php read from file float

开发者 https://www.devze.com 2023-01-09 14:08 出处:网络
Hello I have a text file with three 开发者_运维百科lines. every line has a float number. How can I take each value and put in a float variable even if array?

Hello I have a text file with three 开发者_运维百科lines. every line has a float number. How can I take each value and put in a float variable even if array?

For example text file is like the following

+3.01\n
-0.0012\n
-0.1\n

I want an array [if it possible] which save the values as float not as string.

Thanks


$fileArr = file($fileName);
$fileArr = array_map('floatval', $fileArr);
0

精彩评论

暂无评论...
验证码 换一张
取 消