Doc #65555 [Fbk->NoF]: Example #1 seems to be incorrect.

From: Date: Tue, 15 Oct 2013 11:54:48 +0000
Subject: Doc #65555 [Fbk->NoF]: Example #1 seems to be incorrect.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10496@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65555&edit=1

 ID:               65555
 Updated by:       php-bugs@lists.php.net
 Reported by:      bsasser at sindtech dot net
 Summary:          Example #1 seems to be incorrect.
-Status:           Feedback
+Status:           No Feedback
 Type:             Documentation Problem
 Package:          Documentation problem
 Operating System: n/a
 PHP Version:      Irrelevant
 Private report:   N

 New Comment:

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.


Previous Comments:
------------------------------------------------------------------------
[2013-08-26 09:45:18] yohgaki@php.net

I cannot understand problem.
What is your suggestion improving the doc?

------------------------------------------------------------------------
[2013-08-26 00:26:09] bsasser at sindtech dot net

Description:
------------
---
From manual page: http://www.php.net/function.array-diff-key#refsect1-function.array-diff-key-examples
---
Example #1 *appears* incorrect (based on my own ignorance).

The description of 'array_diff_keys' is written in simple enough English I *should* be
able to see it the way you do (sorry, but I don't).  I must have missed something.

Test script:
---------------
Your example:
$array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3,
'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7,
'cyan'   => 8);

var_dump(array_diff_key($array1, $array2));

Expected result:
----------------
I expected 'purple' to be included in the output because the function "Compares the
keys from array1 against the keys from array2 and returns the difference."

Reading the Return Values portion of the function definition:
"Returns an array containing all the entries from array1 whose keys are not present in any of
the other arrays."

'purple' is included in $array1, but not $array2 - thus a difference.

'cyan' and 'yellow', though technically a 'difference', are not in
$array1 and therefore should not be returned based on the documentation.


Actual result:
--------------
Actual results are identical to those shown in your example #1.


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



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


Thread (3 messages)

« previous php.doc.bugs (#10496) next »