sorted list of tags

OK, this time I’ve revised my PHP code to show a sorted list of labels:

<?php
$dirname = ".";         # current directory
$dir = opendir($dirname);
$file_list = array();
$i = 0;

while (false != ($file = readdir($dir)))
        {
        if (ereg(".html$", $file))
                {
                $tag = substr($file, 0, strlen($file)-5);
                $file_list[$i] = "<li><a href='/labels/$file'>$tag</a>";
                $i++;
                }
        }
closedir($dir);
natcasesort($file_list);
?>
<h1>My Tags</h1>
<ul>
<?php foreach ($file_list as $file) echo($file); ?>
</ul>

Not a big deal, but it does show a (probably) typical use of arrays in PHP. As a side note, the “foreach” construct in PHP is a bit different from the usual foreach in other languages. It’s usually something like “foreach (item in list)”, while in PHP it’s reversed: “foreach (list as item)”. I should also mention that I first tried the regular sort() function, but switched to natcasesort(), since a case-insensitive sort makes more sense here.

Blogger Tags

Well, I wrote a quick PHP script to create a list of tag links that I could display on this page. It should be over to the left. The code is pretty simple:

<?php
$dirname = ".";         # current directory
$dir = opendir($dirname);

while (false != ($file = readdir($dir)))
        {
        if (ereg(".html$", $file))
                {
                $tag = substr($file, 0, strlen($file)-5);
                $file_list .= "<li><a href='/labels/$file'>$tag</a>";
                }
        }
closedir($dir);
?>
<h1>My Tags</h1>
<ul>
<?php echo($file_list); ?>
</ul>

I don’t have the tags showing in any particular order yet, but they’re all there. I just saved this code to a file in the labels directory on my server, then included it in my template with a server-side include.
Also, I should mention that I used this page to format the source code above so it would look OK in a blog post. (Hopefully, it does look ok…)

more Blogger weirdness

I think I just discovered that the post archive settings went slightly wrong at some point, either because of the change over to the new beta, or at some point in the past. Either way, I just fixed it by putting an explicit archive URL in the settings. I think. If the archive links don’t go where they’re supposed to, then maybe not.

Wii Games

Well, I’ve spent a few minutes playing Cars and Super Monkey Ball: Banana Blitz on the Wii. Cars is kind of disappointing. The only use it really makes of the Wii remote is for steering, and it doesn’t seem to work real well for that. I’ll have to give it some more time and see if I get any better at it. SMB, on the other hand, makes pretty good use of the remote. And any game where you’re controlling a monkey in a plastic bubble has got to be good, right?

Blogger Beta

I just switched this blog over to the new Blogger beta. I like having labels (aka tags) built into Blogger — that was overdue. I don’t like the fact that the BlogThis! bookmarklet doesn’t work anymore. And it looks like I can’t put a list of labels on this page for as long as I’m still using the classic template style. I’d have to switch to the new layout scheme.

Nintendo Wii

I bought a Wii yesterday. I wasn’t really planning to get one, but I was Christmas shopping at the Times Square Toys R Us, and they had a bunch of them, so I just picked one up. I figured that if I didn’t like it, it’d be easy enough to get rid of, either on eBay or to someone at work. I’ve only had a chance to play with it a bit today, but so far, I like it. The controller is pretty easy to use and intuitive under Wii Sports. I haven’t tried any other games yet.
This page at ComputerWorld has a good round-up of opinions on the Wii from around the web.

New Jersey Code Camp

I went to New Jersey Code Camp yesterday, but I only stayed for the first two sessions, then I left to go off and take care of something at work. I like the concept. One of the sessions I attended went over my head, I think, while the other one mostly covered stuff I already know. It would have been interesting to stay through the whole thing and see how some of the other sessions shaped up.

The Older Gamers Paradise

I stumbled across 2old2play.com today, a web site for “older gamers.” I guess that’s me, what with me being nearly 40 years old now. I actually haven’t been playing video games much lately — too much other stuff to do. I am kind of curious about the PS3, but not enough to pay $3000 for one on eBay. I’m still playing PS1 games. I’m curious about Final Fantasy XII, too, but I won’t go looking for that until I’ve finished FF VIII, IX, and X first, I think.

hosting

I’ve been hosting this blog on a free “preview” account from 1&1. The deal was for a free account for three years, and those three years are just about up. I just switched over to a $4 per month paid account with the same feature set as the free account. They have a bunch of other options for paid accounts, but, strangely, they don’t match up with the preview account in a logical way. Both their cheaper and more expensive accounts allow more disk space and have a higher monthly transfer allowance, but only the most expensive option allows cron jobs, for instance. Kind of weird, but I haven’t blown the limits on the preview account, so I guess I should be good just continuing it.