note 71492 deleted from function.array-multisort by cmb

From: Date: Sun, 29 Dec 2019 10:28:38 +0000
Subject: note 71492 deleted from function.array-multisort by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213682@lists.php.net to get a copy of this message
Note Submitter: ---- casting the parameter arrays for array_multisort seem to make the sorting ineffective? for example:- <? foreach((array)$report_files as $report_files_i) { $file_stat = stat($report_files_i); $report_files_x[] = array( 'filename' => $report_files_i ,'basename' => basename($report_files_i) ,'ctime' => date("D, M j, Y",$file_stat['ctime']) ,'size' => $file_stat['size'] ); $basename_i[] = strtolower(basename($report_files_i)); // case insensitive } array_multisort($basename_i, SORT_ASC, $report_files_x); ?> The above works but if you change the last time to :- <? array_multisort((array)$basename_i, SORT_ASC, (array)$report_files_x); ?> ...adding the (array) cast doesn't sort the main array ...

« previous php.notes (#213682) next »