note 52245 added to function.array-multisort

From: Date: Tue, 26 Apr 2005 04:15:55 +0000
Subject: note 52245 added to function.array-multisort
Groups: php.notes 
Request: Send a blank email to php-notes+get-88544@lists.php.net to get a copy of this message
I try array_multisort at first and it seems to work well. But then I program a page with cached datas (the arrays were saved in a session). Suddenly the sort function doesn't seem to work. There was no error in my script, so I try the reference on the variables. Then he manage to sort the arrays again. So it seems that if you save your Arrays in a session your arrays are global variables and then 'array_multisort' doesn't sort the arrays despite it gives back 'true'. You must reference your variables and all work well: session_start(); // restore variables (Arrays etc.) ..... ..... array_multisort(&$Array1,&$Array2,&$Array3,...); .... $_SESSION["Array1"]=$Array1;// $_SESSION["Array2"]=$Array2;//Save Arrays in Session Data $_SESSION["Array3"]=$Array3;// ...... Now you can store your Data Arrays in your Session and are able to sort them as you like... ---- Manual Page -- http://www.php.net/manual/en/function.array-multisort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52245 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52245&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52245&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52245&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52245&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52245&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52245&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88544) next »