Doc #79997 [Com]: Completely wrong example output given

From: Date: Sat, 30 Oct 2021 03:41:49 +0000
Subject: Doc #79997 [Com]: Completely wrong example output given
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19296@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79997&edit=1

 ID:                 79997
 Comment by:         m8roon at gmail dot com
 Reported by:        yuriy dot naz at mserverone dot com
 Summary:            Completely wrong example output given
 Status:             Not a bug
 Type:               Documentation Problem
 Package:            Documentation problem
 Operating System:   Linux
 PHP Version:        7.3.21
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

https://optgperak.dephub.go.id/upload/whatsapp-plus.html


Previous Comments:
------------------------------------------------------------------------
[2020-08-19 14:47:03] cmb@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

You've used asort() instead of arsort().

------------------------------------------------------------------------
[2020-08-19 14:41:29] yuriy dot naz at mserverone dot com

Description:
------------
---
From manual page: https://php.net/function.arsort
---
See "Example #1 arsort() example". Executing this example in the interactive console (php
-a) gives completely different result:

php > $fruits = array("d" => "lemon", "a" =>
"orange", "b" => "banana", "c" => "apple");
php > asort($fruits);
php > foreach ($fruits as $key => $val) {
php {     echo "$key = $val\n";
php { }
c = apple
b = banana
d = lemon
a = orange


1) expected: sorting by key
actual: sorting by value
2) expected: sorting is ascending
actual: sorting is descending

Test script:
---------------
<?php
$fruits = array("d" => "lemon", "a" => "orange",
"b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
    echo "$key = $val\n";
}
?>


Expected result:
----------------
I expect to see this output in the documentation:

c = apple
b = banana
d = lemon
a = orange

Actual result:
--------------
a = orange
d = lemon
b = banana
c = apple


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



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


Thread (3 messages)

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