My first ever PHP code

Posted on March 16, 2003 @ 17:16 in General

Hah! Took me about 20 minutes to dig through the documentation at PHP.net and write my first ever snippet of PHP code. To get exactly what I wanted, I needed to tweak it a little, but basically, it worked the very first time I ran it. Whee! And this is it (with some extra dashes in it so it all shows up here and doesn't get eaten either by the server or your browser):

$pieces = explode(" ", "<-$-MTEntryCategory-$->");
$number = count($pieces);
$lower = strtolower($pieces[0]);
print("<-a-href=\"/$lower/\">$pieces[0]<-/-a>");
if ($number > 1) {
print(' » ');
for($i = 1; $i < $number; $i++) {
print("$pieces[$i] ");
}
}
print('<-/-p>');

It may not be the most elegant or intricate thing ever written in PHP, but I'm still quite happy with it.

Comments and Trackbacks

No comments or trackbacks for this entry yet.

Post a comment

Comments and trackbacks have been closed on this site. My apologies.

Since MT-Blacklist inexplicably stopped working I had no other recourse than close comments and trackbacks to stop the spam. I've been meaning to correct this for quite a while, but life got in the way... in a good way I should add.