Skip to content

php SplFileObject and the difference between fgetcsv and current

I had to investigate a bug and figured out a strange behavior in the SplFileObject implementation of php. I know, some of you would add "again", but this does not matter.
To illustrate this problem, I created a little example file. If you run it, you get the following output:


generating content.
..........
writing content.
..........
using fgetcsv and writing key 13 times.
0 0 1 2 3 4 5 6 7 8 9 10 10 
using current and writing key 13 times.
0 0 0 0 0 0 0 0 0 0 0 0 0

As you can see, if you use "fgetcsv", the current key is move to the next step.
If you use "current", the current key won't get updated (which is most likely what you want).
You can easily set the csv delimiter etc. by using setCsvControl()".

web - John Deere and General Motors prevent you from beeing the owner of your car - you are just ... a user now

It’s official: John Deere and General Motors want to eviscerate the notion of ownership. Sure, we pay for their vehicles. But we don’t own them. Not according to their corporate lawyers, anyway.
[...]
Over the last two decades, manufacturers have used the DMCA to argue that consumers do not own the software underpinning the products they buy—things like smartphones, computers, coffeemakers, cars, and, yes, even tractors. So, Old MacDonald has a tractor, but he owns a massive barn ornament, because the manufacturer holds the rights to the programming that makes it run.
(This is an important issue for farmers: a neighbor, Kerry Adams, hasn’t been able to fix an expensive transplanter because he doesn’t have access to the diagnostic software he needs. He’s not alone: many farmers are opting for older, computer-free equipment.)
[...]
It makes sense to John Deere: The company argues that allowing people to alter the software—even for the purpose of repair—would “make it possible for pirates, third-party developers, and less innovative competitors to free-ride off the creativity, unique expression and ingenuity of vehicle software.” [...]

source