php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53468 example 1 for ksort(): match fruit names to index letters
Submitted: 2010-12-03 21:49 UTC Modified: 2010-12-03 21:54 UTC
From: ian at gumstix dot com Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: Irrelevant OS: not applicable
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 - 1 = ?
Subscribe to this entry?

 
 [2010-12-03 21:49 UTC] ian at gumstix dot com
Description:
------------
---
From manual page: http://www.php.net/function.ksort#Examples
---

The example would be clearer if the first letter of each array value matched the corresponding array key, like so:

$fruits = array("l"=>"lemon", "c"=>"cranberry", "a"=>"apple", "b"=>"banana");

Then, when the output is shown, the reader can easily see that key => value mappings are preserved:

a = apple
b = banana
c = cranberry
l = lemon



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-03 21:54 UTC] danbrown@php.net
-Status: Open +Status: Wont fix
 [2010-12-03 21:54 UTC] danbrown@php.net
There's not enough need for that, and - if anything - could potentially introduce 
more of an issue by using a lower-case 'L' in the example.  It's worked fine for 
years.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 20:01:31 2024 UTC