Location: PHPKode > scripts > Name Parser > name-parser/exampleUsage.php
<?php
require_once('nameParser.php');
$names =	file('exampleNames.txt');
$np = new nameParser();
?><table><tr><td><b>Full Name</b></td><td><b>Title</b></td><td><b>First</b></td><td><b>Middle</b></td><td><b>Last</b></td><td><b>Suffix</b></td></tr>
<style type="text/css">
* { padding: 0px; margin: 0px;}
body { margin: 10px; }
td { padding: 5px; background-color: #fff; font-size: 14px; border: 1px solid #ccc;}
.odd { background-color: #eee; }
</style><?

$eo = 1;
foreach($names as $name) {
	if ( $eo == 1 )
		$eoc = "odd";
	else
		$eoc = "";
	$name = trim($name);
	if(!$name) { continue; }
	$np->setFullName($name);
	$np->parse();
	if( !$np->getNotParseable() ) {
		echo "<tr><td class=\"".$eoc."\"><i>".$name."</i></td><td class=\"".$eoc."\">".$np->getTitle()."&nbsp;</td><td class=\"".$eoc."\">";
		echo $np->getFirstName()."&nbsp;</td><td class=\"".$eoc."\">".$np->getMiddleName()."&nbsp;</td><td class=\"".$eoc."\">";
		echo $np->getLastName()."&nbsp;</td><td class=\"".$eoc."\">".$np->getSuffix()."&nbsp;</td></tr>";
	} else {
		echo "<tr><td class=\"".$eoc."\"><i>".$name."</i></td><td class=\"".$eoc."\" colspan=5><center><b>Not parseable.</b></td>\n";
	}
	$eo++;
	if ( $eo == 2 ) $eo = 0;
}
Return current item: Name Parser