To run this script, just add all the names you want to the query_string. Here are some examples:
So pretty much seperate all people by a comma put a NERD: or GEEK: infront if the person is one and if you want to see the code put show_code as a name somewhere.
Enjoy!
<?php
class People {
private $nerds, $geeks, $people;
public function __construct() {
$this->nerds = array('John','John Lindsay','John Lindsay Mullanaphy','John Mullanaphy','Mullanaphy');
$this->geeks = array('Jin','Jin Hee','Jin Hee Kim','Jin Kim','Kim');
$people = func_get_args();
foreach($people as $person) {
if(is_array($person)) { for($i=0;$i<count($person);++$i) { $this->people[] = urldecode($person[$i]); } }
else { $this->person[] = urldecode($person); }
}
}
public function add_nerds() {
$nerds = func_get_args();
if(count($nerds)==0) { return $this->nerds; }
foreach($nerds as $nerd) {
if(is_array($nerd)) {
for($i=0;$i<count($nerd);++$i) {
$this->nerds[] = urldecode($nerd[$i]);
$this->people[] = urldecode($nerd[$i]);
}
}
else {
$this->nerds[] = urldecode($nerd);
$this->people[] = urldecode($nerd);
}
}
$this->nerds = array_unique($this->nerds);
$this->people = array_unique($this->people);
return $this->nerds;
}
public function add_geeks() {
$geeks = func_get_args();
if(count($geeks)==0) { return $this->geeks; }
foreach($geeks as $geek) {
if(is_array($geek)) {
for($i=0;$i<count($geek);++$i) {
$this->geeks[] = urldecode($geek[$i]);
$this->people[] = urldecode($geek[$i]);
}
}
else {
$this->geeks[] = urldecode($geek);
$this->people[] = urldecode($geek);
}
}
$this->geeks = array_unique($this->geeks);
$this->people = array_unique($this->people);
return $this->geeks;
}
public function add_people() {
$people = func_get_args();
if(count($people)==0) { return $this->people; }
foreach($people as $person) { $this->people[] = urldecode($person); }
$this->people = array_unique($this->people);
return $this->people;
}
public function clear() {
$clears = func_get_args();
if(count($clears)==0) {
$this->geeks = array();
$this->nerds = array();
$this->people = array();
return true;
}
foreach($clears as $clear) { $this->$clear = array(); }
return true;
}
public function evaluate() {
$eval = false;
sort($this->people);
foreach($this->people AS $person) {
if(in_array($person,$this->nerds)) { $eval .= '<li>'.$person.' is a nerd but totally rad, and probably likes to buy ice cream for Korean girls.</li>'; }
else if(in_array($person,$this->geeks)) { $eval .= '<li>'.$person.' is a geek, but we will let that slide... However '.$person.' probably likes using a Mac and we won\'t let that slide...</li>'; }
else { $eval .= '<li>'.$person.' is probably mad lame</li>'; }
}
if($eval) { $eval = '<ol>'.$eval.'</ol>'; }
return $eval;
}
}
if(strlen($_SERVER['QUERY_STRING'])>0) {
$pre_query_string = split(',',$_SERVER['QUERY_STRING']);
foreach($pre_query_string as $string) {
if(preg_match('/nerd/i',$string)) {
$string = split(':',$string);
if(!isset($nerds)) { $nerds = split(';',$string[1]); }
else { $nerds = array_merge($nerds,split(';',$string[1])); }
}
else if(preg_match('/geek/i',$string)) {
$string = split(':',$string);
if(!isset($geeks)) { $geeks = split(';',$string[1]); }
else { $geeks = array_merge($geeks,split(';',$string[1])); }
}
else { $query_string[] = $string; }
}
unset($pre_query_string);
}
else { $query_string = array('Jin','John','Bob Costas'); }
foreach($query_string as $person) { if($person!='show_code') { $people[] = $person; } }
$People = new People($query_string);
if(isset($nerds)) { $People->add_nerds($nerds); }
if(isset($geeks)) { $People->add_geeks($geeks); }
print $People->evaluate();
?>
© Mullanaphy! 2009
Not sure why you'd ever need this code however feel free to use and\or modify whatever you want on this page. Go nuts, get crazy, go go ba-nanas!
Last modified: 2010-01-20 19:43:26 EST.
Generated in: 0.012001037597656 seconds.