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. }

No comments: