diff options
| author | Marcus Boerger <helly@php.net> | 2003-11-12 21:43:03 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2003-11-12 21:43:03 +0000 |
| commit | daaef88047db285b4f1d6220651801d244e60312 (patch) | |
| tree | 07b28542ee7ec64a0730333cf17d2733b2b65a26 /ext/dba/dba.c | |
| parent | 2dd35c0e8feeb5e74286723754a518c19b33f3a5 (diff) | |
| download | php-git-daaef88047db285b4f1d6220651801d244e60312.tar.gz | |
Add helper function that splits inifile keys into an array which again
can be used in dba_fetch calls.
Diffstat (limited to 'ext/dba/dba.c')
| -rw-r--r-- | ext/dba/dba.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 7f04229e5b..31ce4827ef 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -66,6 +66,7 @@ function_entry dba_functions[] = { PHP_FE(dba_sync, NULL) PHP_FE(dba_handlers, NULL) PHP_FE(dba_list, NULL) + PHP_FE(dba_key_split, NULL) {NULL, NULL, NULL} }; /* }}} */ @@ -910,6 +911,27 @@ PHP_FUNCTION(dba_fetch) } /* }}} */ +/* {{{ proto array dba_key_split(string key) + Splits an inifile key into an array of the form array(0=>group,1=>value_name) */ +PHP_FUNCTION(dba_key_split) +{ + char *key, *name; + int key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + array_init(return_value); + if (key[0] == '[' && (name = strchr(key, ']')) != NULL) { + add_next_index_stringl(return_value, key+1, name - (key + 1), 1); + add_next_index_stringl(return_value, name+1, key_len - (name - key + 1), 1); + } else { + add_next_index_stringl(return_value, "", 0, 1); + add_next_index_stringl(return_value, key, key_len, 1); + } +} +/* }}} */ + /* {{{ proto string dba_firstkey(int handle) Resets the internal key pointer and returns the first key */ PHP_FUNCTION(dba_firstkey) |
