ID:               24258
 Updated by:       [EMAIL PROTECTED]
 Reported By:      php at electricsurfer dot com
-Status:           Closed
+Status:           Analyzed
 Bug Type:         Feature/Change Request
 Operating System: Win XP
 PHP Version:      5.0.0
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thank you. This feature will be available starting PHP 5.0.0


Previous Comments:
------------------------------------------------------------------------

[2004-01-23 19:24:44] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thank you. This feature will be available starting PHP 5.0.0

------------------------------------------------------------------------

[2004-01-17 12:47:34] [EMAIL PROTECTED]

Unified diff
(http://www.hristov.com/andrey/projects/php_stuff/array_keys_strict.diff.txt):
Index: array.c
===================================================================
RCS file: /repository/php-src/ext/standard/array.c,v
retrieving revision 1.255
diff -u -r1.255 array.c
--- array.c     8 Jan 2004 08:17:30 -0000       1.255
+++ array.c     17 Jan 2004 17:23:55 -0000
@@ -2258,7 +2258,7 @@
 /* }}} */
 
 
-/* {{{ proto array array_keys(array input [, mixed search_value])
+/* {{{ proto array array_keys(array input [, mixed search_value[, bool
strict]])
    Return just the keys from the input array, optionally only for the
specified search_value */
 PHP_FUNCTION(array_keys)
 {
@@ -2266,18 +2266,21 @@
             **search_value,    /* Value to search for */
             **entry,           /* An entry in the input array */
               res,             /* Result of comparison */
+            **strict,          /* be strict */
              *new_val;         /* New value */
        int    add_key;         /* Flag to indicate whether a key should be added
*/
        char  *string_key;      /* String key */
        uint   string_key_len;
        ulong  num_key;         /* Numeric key */
        HashPosition pos;
+       int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) =
is_equal_function;
+
 
        search_value = NULL;
        
        /* Get arguments and do error-checking */
-       if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 ||
-               zend_get_parameters_ex(ZEND_NUM_ARGS(), &input, &search_value) ==
FAILURE) {
+       if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 3 ||
+               zend_get_parameters_ex(ZEND_NUM_ARGS(), &input, &search_value,
&strict) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
@@ -2285,6 +2288,12 @@
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "The first argument
should be an array");
                return;
        }
+       if (ZEND_NUM_ARGS() == 3) {
+               convert_to_boolean_ex(strict);
+               if (Z_LVAL_PP(strict)) {
+                       is_equal_func = is_identical_function;
+               }
+       }
        
        /* Initialize return array */
        array_init(return_value);
@@ -2294,7 +2303,7 @@
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void
**)&entry, &pos) == SUCCESS) {
                if (search_value != NULL) {
-                       is_equal_function(&res, *search_value, *entry TSRMLS_CC);
+                       is_equal_func(&res, *search_value, *entry TSRMLS_CC);
                        add_key = zval_is_true(&res);
                }

------------------------------------------------------------------------

[2003-06-19 09:59:37] php at electricsurfer dot com

Description:
------------
array_keys() would benefit from an optional 3rd parameter called
$strict. array_keys(array input [, mixed search_value [, bool
strict]])) .  This is similar to what in_array() has.  If set to true
it would return an array of keys where value_for_key===search_value.
(not only ==search_value)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24258&edit=1

Reply via email to