Skip to content

Instantly share code, notes, and snippets.

@kkuchta
Created February 12, 2013 02:53
Show Gist options
  • Save kkuchta/4759853 to your computer and use it in GitHub Desktop.
Save kkuchta/4759853 to your computer and use it in GitHub Desktop.
Output is: Array ( [doo] => doobar ) Array ( [doo] => doobar )
<?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