|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9633 sort() not working
Submitted: 2001-03-08 13:43 UTC Modified: 2001-03-09 11:29 UTC
From: sgarin at sgarin dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.0.4pl1 OS: Linux 2.2.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sgarin at sgarin dot com
New email:
PHP Version: OS:


 [2001-03-08 13:43 UTC] sgarin at sgarin dot com
I have an array with random number of elements. I analyse each value (by random selection) and unset it after. In one case, If I unset the first element of my array with 2 elements, sort function does not slide value of the second element to the first element. (sorry for my english). 

Exemple :

  $tb = array (5, 18, 11);
  echo "Values: [0]=$tb[0] [1]=$tb[1] [2]=$tb[2]<BR>";
  unset ($tb[0]);
  echo "After unset: [0]=$tb[0] [1]=$tb[1] [2]=$tb[2]<BR>";
  sort ($tb);
  echo "After sort: [0]=$tb[0] [1]=$tb[1] [2]=$tb[2]<BR>";
  unset ($tb[0]);
  echo "After unset: [0]=$tb[0] [1]=$tb[1]<BR>";
  sort ($tb);
  echo "After sort: [0]=$tb[0] [1]=$tb[1]";

I resolved this trouble by calling implode and explode functions.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-09 11:29 UTC]
try using var_dump() on $tb to figure out what happens,
sort() is fine indeed...
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 03:01:28 2024 UTC