Skip to content

Instantly share code, notes, and snippets.

@kentfredric
Forked from anonymous/question.php
Created November 22, 2012 00:54
Show Gist options
  • Save kentfredric/4128777 to your computer and use it in GitHub Desktop.
Save kentfredric/4128777 to your computer and use it in GitHub Desktop.
IT"S EVEN MORE BEAUTIFUL
<?php
class Question {
public $questionName;
public $choiceValue;
public function __construct($questionName, $choiceValue){
$transtbl = array(
1 => "hate",
2 => "Don't prefer",
3 => "are ok with",
4 => "awesome is the word for",
);
$this->choiceValue = $choiceValue;
if ( array_key_exists( $questionName, $transtbl ) ) {
$name = $transtbl[$questionName];
} else {
$name = "love";
}
$this->questionName = $name;
}
public static function cmp_obj($a, $b)
{
$al = $a->choiceValue;
$bl = $b->choiceValue;
if ($al == bl) {
return 0;
}
return ($al > bl) ? +1 : -1;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment