Created
February 12, 2013 02:53
-
-
Save kkuchta/4759853 to your computer and use it in GitHub Desktop.
Output is: Array ( [doo] => doobar ) Array ( [doo] => doobar )
This file contains 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 | |
class Map{ | |
private $contents = array(); | |
function get( $keyArr ){ | |
return $this->contents[ $this->hash( $keyArr ) ]; | |
} | |
function put( $keyArr, $valArr ){ | |
$this->contents[ $this->hash( $keyArr ) ] = $valArr; | |
} | |
function hash( $arr ){ | |
return @spl_object_hash( $arr ); | |
} | |
} | |
$map = new Map(); | |
$foo = array("foo"=>"foobar"); | |
$doo = array("doo"=>"doobar"); | |
$map->put( $foo, $doo ); | |
print_r( $map->get( $foo ) ); | |
$foo["foo2"] = "foobar2"; | |
print_r( $map->get($foo) ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment