Schlo_50 Posted June 11, 2008 Share Posted June 11, 2008 Hi there, I am working on a script of mine, and one of the requirements is that I need to find the last row of a list I have stored as a .DAT and count the number of values in the row. I can find the last row but am wondering if someone could point out how i'd count the values. For instance my .DAT may look like the following: (I need to find out how many values are in the bottom row.) ID|Email|Name|Description (4 values are in this row) ID|Email|Description (3 values are in this row, which is the one I need the sum of) Can someone help please? The code I have so far finds the last row. $lines = file("./admin/data/candidates.DAT"); $last = $lines[count($lines)-1]; unset($lines); $vals = explode("|", $last); Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/109715-count-suggestions/ Share on other sites More sharing options...
Vizor Posted June 11, 2008 Share Posted June 11, 2008 Well if you are exploding that last row then just use count() to get how many items there are in your array. Quote Link to comment https://forums.phpfreaks.com/topic/109715-count-suggestions/#findComment-562974 Share on other sites More sharing options...
MadTechie Posted June 11, 2008 Share Posted June 11, 2008 if i understand correctly just add this $rows = count($vals)-1; Quote Link to comment https://forums.phpfreaks.com/topic/109715-count-suggestions/#findComment-562975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.