note 78943 deleted from function.array-multisort by nlopess

From: Date: Sat, 03 Nov 2007 22:57:09 +0000
Subject: note 78943 deleted from function.array-multisort by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131974@lists.php.net to get a copy of this message
Note Submitter: zzo38 ---- It doesn't work correctly with references. I fixed it by removing the & sign before $track and adding return $track to the end, and then it works OK. <?php function event_sort(&$track) { $track=array_values($track); $types=array('off'=>'a','meta'=>'b','prog'=>'c', 'control'=>'d', 'on'=>'e','touch'=>'f','bend'=>'g', 'ctouch'=>'h','sysex'=>'i','end'=>'j'); $hashes=array(); foreach($track as $k=>$v) $hashes[$k] = ($v['type']=='end'?'z':'a') . strrev($v['time']) . $types[$v['type']]; array_multisort($hashes,$track); } ?>

« previous php.notes (#131974) next »