diff options
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/standard/basic_functions.c | 6 | ||||
| -rw-r--r-- | ext/standard/php_string.h | 1 | ||||
| -rw-r--r-- | ext/standard/string.c | 30 | ||||
| -rw-r--r-- | ext/standard/tests/strings/lcfirst.phpt | bin | 0 -> 6877 bytes |
4 files changed, 37 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 2639070e55..46c073d7a4 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2624,6 +2624,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_ucfirst, 0) ZEND_END_ARG_INFO() static +ZEND_BEGIN_ARG_INFO(arginfo_lcfirst, 0) + ZEND_ARG_INFO(0, str) +ZEND_END_ARG_INFO() + +static ZEND_BEGIN_ARG_INFO(arginfo_ucwords, 0) ZEND_ARG_INFO(0, str) ZEND_END_ARG_INFO() @@ -3148,6 +3153,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(substr_replace, arginfo_substr_replace) PHP_FE(quotemeta, arginfo_quotemeta) PHP_FE(ucfirst, arginfo_ucfirst) + PHP_FE(lcfirst, arginfo_lcfirst) PHP_FE(ucwords, arginfo_ucwords) PHP_FE(strtr, arginfo_strtr) PHP_FE(addslashes, arginfo_addslashes) diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 6e95503e35..e74609d79b 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -53,6 +53,7 @@ PHP_FUNCTION(strrchr); PHP_FUNCTION(substr); PHP_FUNCTION(quotemeta); PHP_FUNCTION(ucfirst); +PHP_FUNCTION(lcfirst); PHP_FUNCTION(ucwords); PHP_FUNCTION(strtr); PHP_FUNCTION(strrev); diff --git a/ext/standard/string.c b/ext/standard/string.c index 5b0d029d4f..17ebd14f84 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2646,6 +2646,36 @@ PHP_FUNCTION(ucfirst) } /* }}} */ +/* {{{ + Lowercase the first character of the word in a native string */ +static void php_lcfirst(char *str) +{ + register char *r; + r = str; + *r = tolower((unsigned char) *r); +} +/* }}} */ + +/* {{{ proto string ucfirst(string str) + Make a string's first character lowercase */ +PHP_FUNCTION(lcfirst) +{ + char *str; + int str_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + if (!str_len) { + RETURN_EMPTY_STRING(); + } + + ZVAL_STRINGL(return_value, str, str_len, 1); + php_lcfirst(Z_STRVAL_P(return_value)); +} +/* }}} */ + /* {{{ proto string ucwords(string str) Uppercase the first character of every word in a string */ PHP_FUNCTION(ucwords) diff --git a/ext/standard/tests/strings/lcfirst.phpt b/ext/standard/tests/strings/lcfirst.phpt Binary files differnew file mode 100644 index 0000000000..4c5bec898d --- /dev/null +++ b/ext/standard/tests/strings/lcfirst.phpt |
