Reputation: 2261
It seems like a pretty simple issue and one that I thought for sure would have been asked before but I've been searching for some time now and have not found a solution.
When using PHP's file() command, it reads the file and puts each line in an array as a String. Is there any way to read each line as an integer?
(I know that I could just through the array and convert it to an int, but I figure that will slow it down somewhat)
Upvotes: 1
Views: 40
Reputation: 76636
Nope. The only way is to do it manually. Fortunately, that's easy:
$lines = array_map('intval', file($path));
Upvotes: 1