rfc:foreach-non-scalar-keys
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:foreach-non-scalar-keys [2013/02/19 13:15] – nikic | rfc:foreach-non-scalar-keys [2013/02/25 14:51] – Resolve iterator_to_array question nikic | ||
---|---|---|---|
Line 66: | Line 66: | ||
The signature can use '' | The signature can use '' | ||
+ | |||
+ | ===== iterator_to_array() ===== | ||
+ | |||
+ | When using non-string/ | ||
+ | |||
+ | <code php> | ||
+ | function iterator_to_array($iter) { | ||
+ | foreach ($iter as $k => $v) { | ||
+ | $array[$k] = $v; | ||
+ | } | ||
+ | return $array; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | For array and object keys this would give an '' | ||
+ | |||
+ | In order to support this a new function is added in '' | ||
+ | |||
+ | <code c> | ||
+ | /* The refcount of value is incremented by the function itself */ | ||
+ | ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value); | ||
+ | </ | ||
===== Patch ===== | ===== Patch ===== | ||
Line 72: | Line 94: | ||
The change itself is rather small, but there are quite a few extensions that require minor adjustments to use the new API. | The change itself is rather small, but there are quite a few extensions that require minor adjustments to use the new API. | ||
- | |||
- | ===== Open questions ===== | ||
- | |||
- | The main open question are iterator/ |
rfc/foreach-non-scalar-keys.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1