Re: associative arrays

From: Date: Mon, 13 Aug 2001 09:20:54 +0000
Subject: Re: associative arrays
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-63062@lists.php.net to get a copy of this message
That simple, huh? What can I say - You are the man! Thanx Rasmus Lerdorf wrote: > > Ah, ok. It's not much harder: > > pval *tmp_arr; > > array_init(return_value); > MAKE_STD_ZVAL(tmp_arr); > array_init(tmp_arr); > add_assoc_string(tmp_arr, "string index", "foo", 1); > zend_hash_index_update(Z_ARRVAL_P(return_value), 5, &tmp_arr, sizeof(tmp_arr), NULL); > > This will create $whatever[5]['string index'] = 'foo' > > Or if you want a string index at the top level: > > zend_hash_update(Z_ARRVAL_P(return_value), "bar", strlen("bar")+1, > &tmp_arr, sizeof(tmp_arr), NULL); > > This will create $whatever['bar']['string index'] = 'foo'; > > -Rasmus

« previous php.dev (#63062) next »