php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14727 implode() does not implode in order
Submitted: 2001-12-27 19:10 UTC Modified: 2001-12-28 11:25 UTC
From: erathlink5 at lycos dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: win 98
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: erathlink5 at lycos dot com
New email:
PHP Version: OS:

 

 [2001-12-27 19:10 UTC] erathlink5 at lycos dot com
 in multiple array $cards, implode("-",$cards["num"]) differs from concatenated string $cards["num"][...order...]

<?php
/* ?????? ??? ??? ??????? ????????? ??? ?????????? $game, $player */
function tria(&$cards){
echo "In order: " ;
for ($i=1;$i<=24;$i++){
       echo $cards["num"][$i]."-";
       }
echo "<BR>imploded: ";
$periexomeno=implode("-",$cards["num"]);
$aneinai20=implode("-",$cards["d20"]);
echo $periexomeno."<BR>";
}

//-----------------------------------------
function sorthim($poion,&$cards){
        $t=0;
        $kartesoldexei=array(1=>1);
        for ($i=1;$i<=24;$i++){
                            if ((($cards["PiT"][$i])< (8 + ($poion - 1) * 10)) and (($cards["PiT"][$i])>(($poion - 1) * 10))) {
			$t++;
			$kartesoldpoia[$t]=$i;
			$kartesoldpou[$t]=$cards["PiT"][$i];
			$kartesoldexei[$t]=$cards["num"][$i];
                	}  //if end
	}  // for end
        sort ($kartesoldexei);
        for ($i=1;$i<=$t;$i++){
                $cards["num"][$kartesoldpoia[$i]]=$kartesoldexei[$i-1];
                $cards["PiT"][$kartesoldpoia[$i]]=$kartesoldpou[$i];
                }
}
//-------------------------------------END OF FUNCTIONS---------------------------------------
$palia=array(1=>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24);
$cards= array ("num"=>array(1=>1)
,"PiP"=>array(1=>1)
,"PiT"=>array(1=>1),
"d20"=>array(1=>"N")
,"d40"=>array(1=>"N")
,"nine"=>array(1=>"N")
,"can"=>array(1=>"N")
);
for ($i=24;$i;$i--){
      $randval=1;
      if  ($i<>1){
                     mt_srand ((double) microtime() * 1000000);
                     $randval = mt_rand(1,$i) ;
      }
      $cards["num"][$i]=$palia[$randval];
      if ($i<>$randval)
        $palia[$randval]=$palia[$i];
}                             //????  ???????? ?? ?????? ????????????
for ($i=1;$i<=24;$i++){
$cards["PiP"][$i]=$i;
$cards["PiT"][$i]=18;
$cards["d20"][$i]="N";
$cards["d40"][$i]="N";
$cards["nine"][$i]="N";
$cards["can"][$i]="N";
}
mt_srand ((double) microtime() * 1000000);
$randval = mt_rand(0,1) ;
for ($i=1;$i<=6;$i++){
        $cards["PiT"][$i]=$i;
        $cards["PiT"][$i+6]=10+$i;
        }
$cards["PiT"][13]=8;
$x=tria($cards);                 //print sample
$poion=1;
 sorthim ($poion,$cards);
$poion=2;
 sorthim ($poion,$cards);
$x=tria($cards);                //print sample
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-28 11:25 UTC] sander@php.net
Implode works fine.
Probably an error in your script. Ask support questions on php-general@lists.php.net
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 12:01:29 2025 UTC