Showing posts with label Star Wars. Show all posts
Showing posts with label Star Wars. Show all posts

Saturday, March 29, 2008

Finding your Star Wars name

It's high time we did something fun. We're going to write a function that determines a person's Star Wars name.


ASP

  1. function starwarsname(firstName, lastName, maidenName, city)
  2.     starwarsname = Left(firstName, 3) & LCase(Left(lastName, 2)) & " " & Left(maidenName, 2) & LCase(Left(city, 3))
  3. end function

PHP

  1. function starwarsname($firstName, $lastName, $maidenName, $city)
  2. {
  3.     return substr($firstName, 0, 3) . strtolower(substr($lastName, 0, 2)) . " " . substr($maidenName, 0, 2) . strtolower(substr($city, 0, 3));
  4. }