# file count in php

• Cae
• Expert
• Joined: Feb 25, 2004
• Posts: 734
• Status: Offline

April 27th, 2004, 12:17 pm

this is of corse not the correct way of doing it, so if you are just learning java, ignore all this...

49 elements starting count at 0 is 50 elements...

hence when you ant an arry with 50 elements in it you should, i claim, instantiate it by going:
Code: [ Select ]
array = new String[49]

not 50...
• Anonymous
• Bot
• Joined: 25 Feb 2008
• Posts: ?
• Loc: Ozzuland
• Status: Online

April 27th, 2004, 12:17 pm

• Axe
• Genius
• Joined: Jan 07, 2004
• Posts: 5744
• Loc: Sub-level 28
• Status: Offline

April 27th, 2004, 1:19 pm

49 elements starting count at 0 ends up at 48.

You're confusing the issue by using the word "elements" for multiple definitions

If I do something in PHP like...

PHP Code: [ Select ]
\$somevar = array('element1', 'element2', 'element3');

then I do...

PHP Code: [ Select ]
echo \$somevar[0];

\$somevar[0] echo's out the 1st element. Not the 0th Element (there's no such thing as 0th).

\$somevar[49] (if this array extended that far), would be the 50th element. Not the 49th.

The 49th element would be \$somevar[48].
• Scorpius
• Proficient
• Joined: Mar 20, 2004
• Posts: 401
• Loc: Scorpion Hole
• Status: Offline

April 27th, 2004, 2:50 pm

Very well explained. This is also explained well in Calculus using the sigma notation. You can see this page: http://home.alltel.net/okrebs/page136.html
and look at the first image. The top number, 9, is the number you would stop at. The number at the bottom, k=1, is where you would start k. But if this number was 0, you would not only go 9 times in the series, but until it reached 9, which would be 10. So if you would start at 0 and want to go to 9 numbers through the series, you would have to use 8 at the top, or use k=1, which this problem already does.
Hope I helped explain it some, and not confuse you, if Axe did not make it clear enough for you.
• Cae
• Expert
• Joined: Feb 25, 2004
• Posts: 734
• Status: Offline

April 27th, 2004, 3:11 pm

i only used element for 1 definition... each individual slot in the array...

ok... if you start count at 0, and you want a total of 50 elements in your array, you would count from 0 to 49, hence 50 (0 is the first element)... agreed?

now, when you instantiate the array, you put
Code: [ Select ]
blah = new int[50]
for 50 elements... agreed?

but if you want to get the 50th element in the array, its blah[49]

my point is that the two should be the same, you should either start counting at 0 in both cases, or start at 1... not starting at 1 when you instantiate the array, and 0 when utilizing it...

argh... ok, im droping it, i am obviously not getting my point across...
• Axe
• Genius
• Joined: Jan 07, 2004
• Posts: 5744
• Loc: Sub-level 28
• Status: Offline

April 27th, 2004, 3:33 pm

You are getting your point across, but your point isn't the way it works and never will be (by default)

Some languages, however, will allow you to start from 1 not by default, but they will allow it)...

In Pascal for example...

Code: [ Select ]
var something array[1..50] of string;

Then something[1] would be the first element in the array, something[50] would be the 50th array, and something[0] doesn't exist.
• Cae
• Expert
• Joined: Feb 25, 2004
• Posts: 734
• Status: Offline

April 27th, 2004, 4:55 pm

i know its not the way it works, and that it will never be that way... that doesnt mean i have to like it though...

and also, 0 is a number... if you wanted an array with no elements in it it should be (according to me) something[null]
• rtm223
• Mastermind
• Joined: Mar 24, 2004
• Posts: 1855
• Loc: Uk
• Status: Offline

April 27th, 2004, 11:53 pm

Actually, there is a programming language that allows you to do what calendae wants to.....

microsoft visual basic

And if that isn't enough to convince you that it's a bad idea calendae then I have no idea what will
CSS website design tutorials
• ATNO/TW
• Super Moderator
• Joined: May 28, 2003
• Posts: 23407
• Loc: Woodbridge VA
• Status: Offline

April 27th, 2004, 11:57 pm

Hmmm...I'm studying VBA at the moment and my understanding of the concept replicated Axe's explanation. Particularly when it comes to Access 2000 as the base is zero.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
• rtm223
• Mastermind
• Joined: Mar 24, 2004
• Posts: 1855
• Loc: Uk
• Status: Offline

April 28th, 2004, 1:08 am

good point atno. I had only just got out of bed at the time . What I meant was:

Code: [ Select ]
Dim MyArray(49) As Single

Gives you an array of 50 elements labelled 0-49, which gives the consistancy which calendae craves . I just posted in a really dumb way.
Also vb lets you do:

Code: [ Select ]
Dim MyArray(1 to 50) As Single

which I was originally taught as the proper way of doing it (i guess so they didn't confuse us with zero base indexing at the time)

Calendae - I'm not really picking on you BTW lol, I actually only really meant to get accross the point of filesystems (which is the actual topic of the thread , but I guess it's your thread you can do what you like with it.)

As a side note atno - I did access with VBA for my school a-level projects and now I'm doing some stuff in VB6 with an external acess database. I have found the later to give a lot more freedom. I think that it allows for greater portability as the user doesn't need the same version of access as you develop in (but don't hld me to that!)
CSS website design tutorials
• Cae
• Expert
• Joined: Feb 25, 2004
• Posts: 734
• Status: Offline

April 28th, 2004, 11:17 am

ya, we did sortof get away from the topic at hand didnt we... oh well... and i know youre not picking on me rtm... and either way with this radical 'the way arrays are right now is dumb' idea of mine, i probabaly deserve a little...

anyway, i dispise microsoft VB so much, that ill take a little inconsistancy an long as i dont have to use that... *shudders* MVB is the devil... however, i still wish that c++ and java etc were built that way... but im used to it now, so i guess it really doesnt matter... i still think its dumb though...

## Post Information

• Total Posts in this topic: 25 posts
• Users browsing this forum: No registered users and 161 guests
• You cannot post new topics in this forum
• You cannot reply to topics in this forum
• You cannot edit your posts in this forum
• You cannot delete your posts in this forum
• You cannot post attachments in this forum

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.