• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:49
CEST 16:49
KST 23:49
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244ByuL, and the Limitations of Standard Play3
Community News
New 3v3 BGH Ladder (and more) on ShieldBattery!31Weekly Cups (August 17-23): Zerg dominate the week5Weekly Cups (August 10-16): SHIN doubles2GSTL Returns in 2026!45Weekly Cups (Aug 3-9): Protoss get shut out7
StarCraft 2
General
SC4ALL II: SC2 Player Announcement 6/8 - Maru How would you feel about frequent/monthly balance patches for SC2? Balance hotfix patch 5.0.16b (July 16) Weekly Cups (August 17-23): Zerg dominate the week Starcraft2 player guess game is Coming~!
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament 2026 GSTL Announcement IntoTheTV X SOOP SC2 League : Weekly & Monthly PIG STY FESTIVAL 8.0! (13 - 23 August) WORTEX 2026 - Hungarian SC2 Finals Budapest
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 540 Dodge This The PondCast: SC2 News & Results Mutation # 539 Thunder Dome Mutation # 538 Media Blackout
Brood War
General
Pros React To: Calm's Big Brain Play Vs Mini !!!NEW BUG!!! FIRE ARCHONS [Visual] New 3v3 BGH Ladder (and more) on ShieldBattery! BW General Discussion [Personal Project Share] Terran Defense v0.60
Tourneys
[Megathread] Daily Proleagues Escore Tournament - Season 3 [ASL22] Ro24 Group F KCM Race Survival 2026 Season 3
Strategy
Replay Review Process - What do you do? Game Theory for Starcraft Odyssey Mineral Stack Saturation Fighting Spirit mining rates
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Anyone here play Quakeworld back in the day? EVE Corporation
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread Dating: How's your luck?
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Violent Games and Crime Rate…
TrAiDoS
LOCKPICKING NOOB
LUCKY_NOOB
Cathedral Of CS And NY pizza a…
FuDDx
Please support my new stand…
Peanutsc
Customize Sidebar...

Website Feedback

Closed Threads



Active: 10219 users

The Big Programming Thread - Page 190

Forum Index > General Forum
Post a Reply
Prev 1 188 189 190 191 192 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Recognizable
Profile Blog Joined December 2011
Netherlands1552 Posts
Last Edited: 2012-11-10 14:27:52
November 10 2012 14:23 GMT
#3781
On November 10 2012 22:45 myzael wrote:
Show nested quote +
On November 10 2012 21:34 Recognizable wrote:
My first code

from datetime import datetime
now=datetime.now()
print (now)
current_year=now.year
current_month=now.month
current_day=now.day
hour=now.hour
minute=now.minute
second=now.second
slash="/"
print (str(current_day) + (slash) + str(current_month) + (slash) + str(current_year) +" "+ str(hour) + ":" + str(minute) + ":" +str(second))

This is what you'll get: 10/11/2012 13:30:48
I'm going through the python codeacademy classes right now.

Does anyone have a useful site for an overview of the very basics of programming? IE: One that explains what a variable is and lists the types of variables. Codeacademy does this aswell but it doesn't give you a nice overview.


You might want to get used to the following formatting, it is both clearer and more widespread:
print "%s/%s/%s %s:%s:%s" % (str(current_day), str(current_month), str(current_year), str(hour), str(minute), str(second))


Also, you don't need that many brackets.

Furthermore, not trying to be rude or smartass, but python is about clarity IMO.
from datetime import datetime
print datetime.now().strftime("%d/%m/%Y %H:%M:%S")


As for introduction. You are trying to write in python. Why not start with this: http://docs.python.org/2.7/tutorial/introduction.html ?


The codeacademy site suggested I used concatenation. I get what you are saying with clarity, but this was given to me to figure out how to get the time, so I kinda just went along. In total I have about 1.5 hours of coding experience ^.^
now=datetime.now()
print (now)
current_year=now.year
current_month=now.month
current_day=now.day
myzael
Profile Blog Joined November 2008
Poland605 Posts
November 10 2012 16:44 GMT
#3782
Well it is for you to decide what is clearer

Also, I am not saying that you should write a whole web-app with minimal experience, it is natural to write code in a way as you do, being a beginner. I was there, too. Hell, I was much, much worse!

You should just focus on writing progressively better code. It should be as short as possible, but not at the cost of readability. That's my point of view at least.

Keep it up!
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
November 10 2012 21:08 GMT
#3783
Hey, this isn't really a programming question, but more of a computer science/programming knowledge question. Would it be a good idea to take classes on ring/group/field/coding theory (In mathematics)?

I'm wondering because I'm taking a Comp Sci degree at University, and next term I have a free class to take anything I want. I'd like to take something related to my major or that can help me build a broader knowledge base, but I literally can't fit any comp sci class into my schedule as it is, so I'm looking for other alternatives.

A couple of weeks ago, there was quite a long discussion on integer factorization, and that got me reading about different algorithms for factorization, and how it applies to cryptography, and so on. One thing I noticed, is that there was a lot of application of group/field theory to solving this problem, and it piqued my interest. Looking it up later, I saw there are multiple classes out of the Math department on the subject, and they'd actually fit my schedule. I've already taken a couple of Linear Algebra courses, so I have the pre-req's already too.

So, what I'm basically wondering, is if taking Math classes on more advanced algebra would be practically useful, or if it wouldn't really mean anything unless I went on to a PhD program or something where you deal more with theory.

Here's the course description if anyone cares:
+ Show Spoiler +
Integers. Mathematical induction. Equivalence relations. Commutative rings, including the integers mod n, complex numbers and polynomials. The Chinese remainder theorem. Fields and integral domains. Euclidean domains, principal ideal domains and unique factorization. Quotient rings and homomorphisms. Construction of finite fields. Applications such as public domain encryption, Latin squares and designs, polynomial error detecting codes, and/or addition and multiplication of large integers.

After this, I could take further courses on either coding theory, or move into group/field theory.

Any advice would be appreciated. Yay, math! :p
you gotta dance
Fyodor
Profile Blog Joined September 2010
Canada971 Posts
November 10 2012 21:48 GMT
#3784
On November 11 2012 06:08 Mr. Wiggles wrote:
Hey, this isn't really a programming question, but more of a computer science/programming knowledge question. Would it be a good idea to take classes on ring/group/field/coding theory (In mathematics)?

I'm wondering because I'm taking a Comp Sci degree at University, and next term I have a free class to take anything I want. I'd like to take something related to my major or that can help me build a broader knowledge base, but I literally can't fit any comp sci class into my schedule as it is, so I'm looking for other alternatives.

A couple of weeks ago, there was quite a long discussion on integer factorization, and that got me reading about different algorithms for factorization, and how it applies to cryptography, and so on. One thing I noticed, is that there was a lot of application of group/field theory to solving this problem, and it piqued my interest. Looking it up later, I saw there are multiple classes out of the Math department on the subject, and they'd actually fit my schedule. I've already taken a couple of Linear Algebra courses, so I have the pre-req's already too.

So, what I'm basically wondering, is if taking Math classes on more advanced algebra would be practically useful, or if it wouldn't really mean anything unless I went on to a PhD program or something where you deal more with theory.

Here's the course description if anyone cares:
+ Show Spoiler +
Integers. Mathematical induction. Equivalence relations. Commutative rings, including the integers mod n, complex numbers and polynomials. The Chinese remainder theorem. Fields and integral domains. Euclidean domains, principal ideal domains and unique factorization. Quotient rings and homomorphisms. Construction of finite fields. Applications such as public domain encryption, Latin squares and designs, polynomial error detecting codes, and/or addition and multiplication of large integers.

After this, I could take further courses on either coding theory, or move into group/field theory.

Any advice would be appreciated. Yay, math! :p

Depends on what you mean by practical.

Will you really need to use what that class taught you within the next 2 years? The answer is probably no, depending on what you wanna do.

Will having that class help you find a job? Probably not.

Will the knowledge offered in class help you solve a big problem in CS? Possibly.

Is it a good idea to study something that interests you and has possible applications in your field? Yes.

Just read more on it and see if this is something you want to wager on.
llllllllllllllllllllllllllllllllllllllllllll
Kambing
Profile Joined May 2010
United States1176 Posts
November 10 2012 21:53 GMT
#3785
On November 11 2012 06:08 Mr. Wiggles wrote:
Hey, this isn't really a programming question, but more of a computer science/programming knowledge question. Would it be a good idea to take classes on ring/group/field/coding theory (In mathematics)?

I'm wondering because I'm taking a Comp Sci degree at University, and next term I have a free class to take anything I want. I'd like to take something related to my major or that can help me build a broader knowledge base, but I literally can't fit any comp sci class into my schedule as it is, so I'm looking for other alternatives.

A couple of weeks ago, there was quite a long discussion on integer factorization, and that got me reading about different algorithms for factorization, and how it applies to cryptography, and so on. One thing I noticed, is that there was a lot of application of group/field theory to solving this problem, and it piqued my interest. Looking it up later, I saw there are multiple classes out of the Math department on the subject, and they'd actually fit my schedule. I've already taken a couple of Linear Algebra courses, so I have the pre-req's already too.

So, what I'm basically wondering, is if taking Math classes on more advanced algebra would be practically useful, or if it wouldn't really mean anything unless I went on to a PhD program or something where you deal more with theory.

Here's the course description if anyone cares:
+ Show Spoiler +
Integers. Mathematical induction. Equivalence relations. Commutative rings, including the integers mod n, complex numbers and polynomials. The Chinese remainder theorem. Fields and integral domains. Euclidean domains, principal ideal domains and unique factorization. Quotient rings and homomorphisms. Construction of finite fields. Applications such as public domain encryption, Latin squares and designs, polynomial error detecting codes, and/or addition and multiplication of large integers.

After this, I could take further courses on either coding theory, or move into group/field theory.

Any advice would be appreciated. Yay, math! :p


Abstract algebra is certainly useful with its applications to number theory, cryptography, and coding theory. Abstract algebra is also useful because the ideas can be directly applied to programming and reasoning about programs.

For example, in functional programming (e.g., Haskell and Scala), certain computations can be expressed in terms of monoids (a semigroup --- a set with a binary operation over that set --- coupled with an identity element), e.g,. list concatenation, addition over integers, union over sets. We can thus write a generic program that allows us to traverse a data structure, e.g., a list or tree, and do these monoid-al operations over these data structures without duplicating code.
Watercrystal
Profile Blog Joined May 2011
58 Posts
November 11 2012 00:58 GMT
#3786
Hey guys,
I'm currently in the Process of learning Java for my CS class (11th grade in Germany, dunno what it would equal to in the American school system). As I progress faster than the others, my teacher allowed me to work on a project of my choice and I chose to do a Pokemon-stlye of Game, so I informed myself a bit about how to approach a game programming-wise. I got a "working" game loop. Now I want to go on by building a simple 2D engine going, but I had no clue how to get on it, so I searched for a bit of help and found that: http://de.twitch.tv/notch/b/302823358 (The -in my perspective- interesting part starts at 42:50). That guy does exactly what I want to achieve, but I dont understand what he's doing at all. I just see crazy amounts of bitwise operations (If I'm not mistaken; those << and >> operators are used for bitwise operations, aren't they?).
Can you give me a quick outline of what he does/shoot me a link where a similar thing is explained?

Thank you
Kambing
Profile Joined May 2010
United States1176 Posts
Last Edited: 2012-11-11 01:15:01
November 11 2012 01:14 GMT
#3787
On November 11 2012 09:58 Watercrystal wrote:
Hey guys,
I'm currently in the Process of learning Java for my CS class (11th grade in Germany, dunno what it would equal to in the American school system). As I progress faster than the others, my teacher allowed me to work on a project of my choice and I chose to do a Pokemon-stlye of Game, so I informed myself a bit about how to approach a game programming-wise. I got a "working" game loop. Now I want to go on by building a simple 2D engine going, but I had no clue how to get on it, so I searched for a bit of help and found that: http://de.twitch.tv/notch/b/302823358 (The -in my perspective- interesting part starts at 42:50). That guy does exactly what I want to achieve, but I dont understand what he's doing at all. I just see crazy amounts of bitwise operations (If I'm not mistaken; those << and >> operators are used for bitwise operations, aren't they?).
Can you give me a quick outline of what he does/shoot me a link where a similar thing is explained?

Thank you


Hoping into Notch's livestream of him working on his Ludem Dare project is probably not a productive way to start out. You won't really get a sense of the bigger picture from watching that video alone.

If you are intent on building a simple 2D game engine, I recommend looking elsewhere than that video for a source of information. Perusing r/gamedev for beginning tutorials is a good place to start. I rarely recommend textbooks, but Rabin's Introduction to Game Development is a good starting resource for understanding how to build a game engine.

Alternatively, if you are interested in building a game (and the engine is uninteresting), you should look into frameworks such as Unity3D that will help you get your ideas off the ground without having to build everything from scratch. (Since you are talking about this in the context of intro CS, this is probably not what you want, but its good to know that these kinds of resources are out there.)
Watercrystal
Profile Blog Joined May 2011
58 Posts
November 11 2012 01:22 GMT
#3788
Okay, thank you. I will check out reddit, didn't know there was a subreddit for that :D
Thank you
RayzorFlash
Profile Joined December 2010
Canada253 Posts
November 11 2012 01:32 GMT
#3789
Okay so, I was recently asked at a job interview to create a linked list class (either singly or doubly, doesnt matter) in C/C++ and use it to do common functions, such as insert/delete/iterate, etc.

Now once I was done this, which was pretty straightforward, the second part of the question was to do the same thing except without using the "new" or "delete" commands (or malloc/realloc if you chose C). This part completely stumped me and basically made me lose out on a job (very sad )

Anyways, I was wondering if someone has any tips on how one would go about doing this? Thanks!!
Craton
Profile Blog Joined December 2009
United States17303 Posts
November 11 2012 01:35 GMT
#3790
On November 10 2012 22:10 FFGenerations wrote:
thanks for replies, i have a better idea of what might have happened now. might have been something like, i doubleclicked the form randomly then deleted the auto code

If you spend any amount of time developing .NET, you will do this over and over again.

In some cases it knows to remove the associated event, but in some cases it doesn't. I haven't really figured out what the criteria is.
twitch.tv/cratonz
Kambing
Profile Joined May 2010
United States1176 Posts
November 11 2012 01:40 GMT
#3791
On November 11 2012 10:32 RayzorFlash wrote:
Okay so, I was recently asked at a job interview to create a linked list class (either singly or doubly, doesnt matter) in C/C++ and use it to do common functions, such as insert/delete/iterate, etc.

Now once I was done this, which was pretty straightforward, the second part of the question was to do the same thing except without using the "new" or "delete" commands (or malloc/realloc if you chose C). This part completely stumped me and basically made me lose out on a job (very sad )

Anyways, I was wondering if someone has any tips on how one would go about doing this? Thanks!!


I would have asked the interviewer what he meant by that. new/malloc just allocates space on the heap, so your only recourse is to stack allocate or globally allocate a large chunk of memory and manually slice chunks out of that yourself. In essence, you would end up implementing your own heap, which may have been the point of the problem given that you started with a linked list.
RayzorFlash
Profile Joined December 2010
Canada253 Posts
November 11 2012 01:49 GMT
#3792
On November 11 2012 10:40 Kambing wrote:
I would have asked the interviewer what he meant by that. new/malloc just allocates space on the heap, so your only recourse is to stack allocate or globally allocate a large chunk of memory and manually slice chunks out of that yourself. In essence, you would end up implementing your own heap, which may have been the point of the problem given that you started with a linked list.


Thanks. The clarifications I received after I admitted that I was stumped did imply that this is what they were looking for. They suggested to have a pre-allocated space, which could be a linked-list itself, from which the nodes would be removed as required, have data changed to what was needed, and then inserted to the actual linked list. However, I didn't quite understand how one would go about allocating that space or creating the "unused nodes" linked list without using new. I just couldn't wrap my head around any way to CREATE the heap itself without using new. How would I go about doing this?

Also, constraints clarification: memory usage was not a constraint for the problem, but minimizing runtime was a primary concern
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-11-11 02:22:27
November 11 2012 01:53 GMT
#3793
On November 11 2012 10:32 RayzorFlash wrote:
Okay so, I was recently asked at a job interview to create a linked list class (either singly or doubly, doesnt matter) in C/C++ and use it to do common functions, such as insert/delete/iterate, etc.

Now once I was done this, which was pretty straightforward, the second part of the question was to do the same thing except without using the "new" or "delete" commands (or malloc/realloc if you chose C). This part completely stumped me and basically made me lose out on a job (very sad )

Anyways, I was wondering if someone has any tips on how one would go about doing this? Thanks!!

Sounds like he either wanted you to use memory pools from something like VirtualAlloc, or to use a pre-allocated array of nodes (if it isn't templated). There's a lot of ways to do this.

Edit:
Well you declare a global or static array. You can use a global array of characters and treat that as a byte array. Then whenever you need to grab memory for a node you can handle the memory management yourself, instead of relying on new to go ask the operating system for memory. This would have very little overhead during run-time in terms of allocation time compared to raw new or malloc calls.

If you did indeed lose the position you really should have known what new and delete are doing before you use them. If you want to be prepared for an interview write your own new and delete (memory manager), write your own STL-mimic containers, and implement sorting algorithms with them.
tuho12345
Profile Blog Joined July 2011
4482 Posts
November 11 2012 02:13 GMT
#3794
Hey guys, so I'm designing a software for my visual basic class. Where I need to access the database, search for the student, display on the listbox and when I click on it, it will appear the infor of that student on the next page

So on the list box, an option should be like Firstname, lastname, school, major, email. All of them as a string
Now I need to use array or some sort of method to display that item and I'm not sure how. A friend show me how to use substring for the Firstname but then since I haven't studied substring yet, I don't know the rest either.

Please help me on this, thanks.
RayzorFlash
Profile Joined December 2010
Canada253 Posts
Last Edited: 2012-11-11 02:31:38
November 11 2012 02:21 GMT
#3795
On November 11 2012 10:53 CecilSunkure wrote:
If you did indeed lose the position you really should have known what new and delete are doing before you use them. If you want to be prepared for an interview write your own new and delete (memory manager), write your own STL-mimic containers, and implement sorting algorithms with them.


Will do, thanks! I felt I did really well on the interview overall aside from completely blanking out on that question. I do know what new/delete do, I just couldn't think of any way to create a linked list without using them. I'm digging into using the char array and will see how that works out.

Btw, do you know some good documentation I can look over to get started on STL? I've wanted to wrap my head around that for a while, and it surprisingly wasn't covered at all in any of my university courses

Edit: Lol, wow that was stupid of me... I just implemented the static array solution in the replica code I was writing up at home, and I'm now having d'oh moment... Can't believe I screwed up on a question with such a simple solution, lol... Thanks a lot, though!!!
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-11-11 02:35:18
November 11 2012 02:31 GMT
#3796
On November 11 2012 11:21 RayzorFlash wrote:
Show nested quote +
On November 11 2012 10:53 CecilSunkure wrote:
If you did indeed lose the position you really should have known what new and delete are doing before you use them. If you want to be prepared for an interview write your own new and delete (memory manager), write your own STL-mimic containers, and implement sorting algorithms with them.


Will do, thanks! I felt I did really well on the interview overall aside from completely blanking out on that question. I do know what new/delete do, I just couldn't think of any way to create a linked list without using them. I'm digging into using the char array and will see how that works out.

Btw, do you know some good documentation I can look over to get started on STL? I've wanted to wrap my head around that for a while, and it surprisingly wasn't covered at all in any of my university courses

Like how to use STL? The only STL containers I've used so far is map, vector and list. I just googled std::map, std::vector and std::list.

Edit:
If you know what new and delete do already, then why were you stumped on the interview question There's an awesome article on how to make a highly optimized allocator in game engine gems 2. It uses some really interesting bit manipulation to squeeze in as much as possible to allow pages of the manager to fit in whole inside of small cache sizes.
RayzorFlash
Profile Joined December 2010
Canada253 Posts
November 11 2012 02:33 GMT
#3797
On November 11 2012 11:31 CecilSunkure wrote:
Like how to use STL? The only STL stuff containers I've used so far is map, vector and list. I just googled std::map, std::vector and std::list.


I've heard a couple of people say theres some stuff in STL that is really useful for implementing hash tables, and since I'm often asked about hash tables on interviews, I feel there's some merit to knowing that, and was wondering if you knew somewhere to start regarding that
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
November 11 2012 02:36 GMT
#3798
On November 11 2012 11:33 RayzorFlash wrote:
Show nested quote +
On November 11 2012 11:31 CecilSunkure wrote:
Like how to use STL? The only STL stuff containers I've used so far is map, vector and list. I just googled std::map, std::vector and std::list.


I've heard a couple of people say theres some stuff in STL that is really useful for implementing hash tables, and since I'm often asked about hash tables on interviews, I feel there's some merit to knowing that, and was wondering if you knew somewhere to start regarding that

Can try this: http://www.randygaul.net/2012/07/01/hash-tables-introduction/
white_horse
Profile Joined July 2010
1019 Posts
Last Edited: 2012-11-11 03:58:22
November 11 2012 03:58 GMT
#3799
On November 10 2012 13:47 tec27 wrote:
I hope you get this figured out, but I think you're really disadvantaging yourself. You've posted code for help like this pretty much every week without fail. From the thread rules:
Show nested quote +
2. Don't post a huge block of code and ask "what's wrong?" or I'll smack you.

There's a few reasons for this rule, I think. Number one is that it makes the thread pretty noisy and irrelevant to the vast majority of readers. Number two is that it doesn't promote interesting discussion. Number three is that it prevents you from learning how to figure out your own mistakes. This is especially evident from how many times you've come back here to ask the same sorts of things. I know, the learning curve is tough, but you have to push through that if you want to *actually* figure this stuff out.

I (and I'm sure a lot of other people) would appreciate it if you didn't post your homework in here every week. Homework threads are also banned on TL, I don't see why homework posts would be allowed considering that


Sorry, I didn't know such a rule existed. thanks for letting me know. I'm pretty much done with the code now after working on it for a few hours. Thanks to everyone who helped me. And I'll try not to do this too often.

someone mentioned that he wrote something long for me but that I didnt respond. I probably didn't see it so sorry about that
Translator
chrisolo
Profile Joined May 2009
Germany2610 Posts
November 11 2012 21:08 GMT
#3800
I hope this belongs into this.

I have a problem in PHP. I am reading out a directory and want to sort it. So I defined and array and try to sort it by sort(), but I cannot bring it to work. My PHP time is quite some time ago, so this might be obvious.

Here is the relevant code-snippet:
+ Show Spoiler +

$dir = array();


$handle = opendir("replays");
$repz = "-2";
while ($datei = readdir ($handle)) {
$repz++;
}
closedir($handle);


echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr><td align=\"center\">
<br><br><b>Content of the Replayarchive</b>
</td></tr>
<tr><td width=\"100%\" align=\"center\"><br>";
$verz=opendir (''.$_SERVER[DOCUMENT_ROOT].'/'.$pfad.'/.');
while ($File = readdir ($verz)) {
if($File != '.' && $File != '..' && $File != '.htaccess') {
$dir[] = $file;
}
sort($dir);
echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"50%\"><tr><td align=\"left\"> ";
foreach(§dir as $File){
if(is_dir($pfad."/".$File)){
if($dl_link==1){
echo "<img width=\"11\" height=\"11\" src=\"./img/$li_bild\" alt=\"\" name=\"li\"><a href=\"replays/$File\" target=\"_blank\" > $File</a>";
}
else{
echo " <img width=\"11\" height=\"11\" src=\"./img/$li_bild\" alt=\"\" name=\"li\"> $File";
}
echo "</td></tr></table>";}
}
}


Can anyone help me please? Would be REALLY nice if you could just fix it (I guess it is just a matter of ten seconds or something), but if you do not want to fix it directly please tell me what I am doing wrong
¯\_(ツ)_/¯ - aka cReAtiVee
Prev 1 188 189 190 191 192 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 41m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Serral 1818
Trap 14
StarCraft: Brood War
Britney 45116
Calm 6722
Shuttle 2671
actioN 2412
EffOrt 704
Mini 607
BeSt 273
Pusan 251
firebathero 219
Rush 180
[ Show more ]
Soulkey 179
Snow 155
Zeus 124
Sea.KH 65
Hyun 56
Mong 46
ToSsGirL 46
Aegong 36
Barracks 32
Terrorterran 24
zelot 24
Hm[arnc] 19
soO 19
Bale 17
Noble 14
scan(afreeca) 13
Shine 12
Free 12
yabsab 11
sorry 10
Sacsri 8
Dota 2
Gorgc5467
qojqva3075
syndereN333
BananaSlamJamma126
Counter-Strike
fl0m3816
Other Games
singsing2291
crisheroes514
B2W.Neo470
Lowko296
Beastyqt265
Hui .210
DeMusliM193
ToD166
Liquid`VortiX163
ArmadaUGS103
KnowMe79
QueenE52
Rex51
Trikslyr1
Organizations
Other Games
gamesdonequick2432
StarCraft: Brood War
lovetv 8
[ Show 15 non-featured ]
StarCraft 2
• poizon28 25
• mYiSmile16
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• HerbMon 13
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV655
League of Legends
• Jankos1710
• Nemesis1644
• TFBlade846
Upcoming Events
RotterdaM Event
1h 41m
The PiG Daily
6h 11m
BASILISK vs TBD
Serral vs Rogue
Korean StarCraft League
11h 11m
GSL
20h 11m
Replay Cast
1d 9h
WardiTV Weekly
1d 20h
Sparkling Tuna Cup
2 days
Afreeca Starleague
2 days
GSL
3 days
PiGosaur Cup
4 days
[ Show More ]
Replay Cast
5 days
The PondCast
5 days
IntoTheTV X SOOP
6 days
Liquipedia Results

Completed

Proleague 2026-08-27
PiG Sty Festival 8.0
META DYMY #4

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL Season 22: Qualifier 2
RSL Revival: Season 6
Light Tournament 2026
BLAST Open Fall 2026
Esports World Cup 2026
Esports World Cup 2026: LCQ
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026

Upcoming

BSL 2026 LAN: Kraków
CSL 2026 AUTUMN (S22)
Escore Tournament S3: King of Kings
Acropolis #5
Acropolis #5 - TRS
Blizzard Classic Cup 2026
Acropolis #5 - GSA
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Calamity Invitational
Big Dog Cup 2026 Div 1
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.