note 37099 deleted from language.types.array by curt

From: Date: Tue, 06 Jul 2004 02:26:01 +0000
Subject: note 37099 deleted from language.types.array by curt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72649@lists.php.net to get a copy of this message
Note Submitter: plintus@smtp.ru ---- Sometimes you need to associate an array with some kind of value, so you want to do the following: $a = array ( array (...) => 'good_array', array (...) => 'big_array', array (...) => 'green_array' ); But this is not possible. While you cannot use an array as a key of another array, you still can do this: $a = array ( serialize (array (...)) => 'good_array', serialize (array (...)) => 'big_array', serialize (array (...)) => 'green_array' ); That's because serialize() returns strings, which can be a keys of an array. Now if you want to know, whether array $b is good, big or green, you can just do the following: echo $a[serialize ($b)]; Hope it helps (tm) :-)

« previous php.notes (#72649) next »