Created
September 17, 2012 23:29
-
-
Save brodock/3740390 to your computer and use it in GitHub Desktop.
GroupArray
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Estrutura de dados semelhante ao Array() do php, que permite armazenar mais | |
* de um dado em uma mesma chave | |
* | |
* @author Gabriel Mazetto | |
*/ | |
class GroupArray { | |
private $data = array(); | |
function add($key, $value) { | |
if (!array_key_exists($key, $this->data)) { | |
$this->data[$key] = array(); | |
} | |
array_push($this->data[$key], $value); | |
} | |
function get($key) { | |
return $this->data[$key]; | |
} | |
function get_assoc() { | |
return $this->data; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment