array

Posts Tagged array

Write more compact php code

Thursday, July 10th, 2008 in PHP | 4 comments

I’ve been programming using and MySQL for about 4 years by now. One thing that I’ve always hated was to write code. Don’t get me wrong, I love coding, what I hate is writing in 10 lines what I could do in 5. Besides the fact that is a terrible waste of time and effort, when I was put in the position of revising the code at a later time (to make changes or just for the sake of improving the code) I found myself in trouble trying to understand what the hell I was thinking back then. Another scenario is when someone else is taking what you started ( I know this because I had to take on someone else’s projects ).

Giving this, why not spend a little time thinking first and then start coding? Below are a few things I’ve found out with time. (more…)

Tags: , , ,

PHP read directory

Tuesday, October 30th, 2007 in PHP | 11 comments

The other day I found myself having a problem with not empty directories. I had to delete a directory that had another directory in it that contained a file. Giving the fact that I’m a lazy programmer, I had to find an easy enough solution to use then and every time I needed it without doing much work every time.

So I came up with a class that reads the whole directory, it stores in 2 different arrays all the files and subdirectories (the full path to them, starting with the given directory) and than it deletes them if one wants to do that. If you need such code use the one below. It worked fine for me so it should read the directories for you too. Here goes: (more…)

Tags: , , ,