function parse_author( $author ) { $matches = array(); if (preg_match( "/(\w.*\b) *, *(\b.*\w)/", $author, $matches)) { $first = $matches[2]; $last = $matches[1]; } elseif (preg_match( "/(\w.*\b) (\w+)/", $author, $matches)) { $first = $matches[1]; $last = $matches[2]; } elseif (preg_match( "/(\w+)/", $author, $matches)) { $first = ""; $last = $matches[1]; } else { $first = ""; $last = "Unknown"; } return array( $first, $last ); }