Return to Snippet

Revision: 54816
at January 13, 2012 01:53 by serialk89


Initial Code
/*
	* Objetivo ordena un array dimensional 
	*/
	function orderMultiDimensionalArray ($toOrderArray, $field, $inverse = false) {  
        $position = array();  
        $newRow = array();  
        foreach ($toOrderArray as $key => $row) {  
                $position[$key]  = $row[$field];  
                $newRow[$key] = $row;  
        }  
        if ($inverse) {  
            arsort($position);  
        }  
        else {  
            asort($position);  
        }  
        $returnArray = array();  
        foreach ($position as $key => $pos) {       
            $returnArray[] = $newRow[$key];  
        }  
        return $returnArray;  
    }

Initial URL

                                

Initial Description
Ordena Array Bidimensional Asociativo de acuerdo a parametro del array.

Initial Title
Ordenar array bidimensional por parametro

Initial Tags
php, array, order

Initial Language
PHP