Re: Hash Functions API

From: Date: Thu, 12 Apr 2001 05:40:42 +0000
Subject: Re: Hash Functions API
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-51484@lists.php.net to get a copy of this message
["Brian Foddy" <bfoddy@mn.mediaone.net>] > I've been looking everywhere for a good reference of how to read and > update arrays. The Zend documentation > (www.zend.com/apidoc) has descriptions of how to create > an array, and how to add elements to it, but I can't find anything on how > to simply read the values of an array. > > Mostly I want to write two functions: > 1. Accept a provided 2 dimensional array and loop through > every element, by primary index then an inner loop by the second index, > sequentially. I need to extract from the array the two keys and the > value. The keys will not be sequential, at least the primary. > > 2. Build a 2-d array, basically the reverse of 1 above. Build an array > with specific primary and secondary indexes. Again keys will not > be sequential. > > To make matters worse, I'd like the keys to be either integer or strings. > > I've looked through the zend_hash.h header, and a few functions look > likely (zend_hash_move_forward, zend_hash_get_current_key). Those are the ones you want, plus zend_hash_get_current_data. > But its hard knowing if these are the best to use and exactly how to use > them. > > One more question, very simple. What is the difference between > zend_hash_find and quick_find? I assume index_find lets me specify > an integer (ie: array[3] in C notation). The only difference is that zend_hash_find is smart about numeric string indexes. For example, if the array has a key with the integer value 4, doing zend_hash_find after the string key "4" will still find it. zend_hash_quick_find doesn't do this. > Have I missed the docs on these functions somewhere? I don't think so? :-) - Stig -- Stig Sæther Bakken <ssb@fast.no> Fast Search & Transfer ASA, Trondheim, Norway

« previous php.dev (#51484) next »