Ordinare array multi-dimensionale in PHP

Here’s another approach using uasort() and an anonymous callback function (closure). I’ve used that function regularly. PHP 5.3 required – no more dependencies!

 * Sorting array of associative arrays - multiple row sorting using a closure.
 * See also: http://the-art-of-web.com/php/sortarray/
 * @param array $data input-array
 * @param string|array $fields array-keys
 * @license Public Domain
 * @return array
function sortArray( $data, $field ) {
    $field = (array) $field;
    uasort( $data, function($a, $b) use($field) {
        $retval = 0;
        foreach( $field as $fieldname ) {
            if( $retval == 0 ) $retval = strnatcmp( $a[$fieldname], $b[$fieldname] );
        return $retval;
    } );
    return $data;

/* example */
$data = array(
    array( "firstname" => "Mary", "lastname" => "Johnson", "age" => 25 ),
    array( "firstname" => "Amanda", "lastname" => "Miller", "age" => 18 ),
    array( "firstname" => "James", "lastname" => "Brown", "age" => 31 ),
    array( "firstname" => "Patricia", "lastname" => "Williams", "age" => 7 ),
    array( "firstname" => "Michael", "lastname" => "Davis", "age" => 43 ),
    array( "firstname" => "Sarah", "lastname" => "Miller", "age" => 24 ),
    array( "firstname" => "Patrick", "lastname" => "Miller", "age" => 27 )

$data = sortArray( $data, 'age' );
$data = sortArray( $data, array( 'lastname', 'firstname' ) );


Una classe PHP per recuperare regioni province e citta da file

class CRegione
var $id;
var $ripartizioneGeografica;
var $codice;
var $nome;

function CRegione($id, $ripartizioneGeografica, $codice, $nome)
$this->id = trim($id);
$this->ripartizioneGeografica = trim($ripartizioneGeografica);
$this->codice = trim($codice);
$this->nome = trim($nome);

function CreaTabellaSQL()
return "CREATE TABLE regioni(id int not null auto_increment primary key, ripartizione_geografica tinytext, codice int, nome tinytext);\n";

function GeneraSQL()
$arrValori = array(
$strValori = implode(',', $arrValori);
$sql="INSERT INTO regioni(ripartizione_geografica, codice, nome) VALUES (".$strValori.");\n";
return $sql;

Continue reading

Ghost Recon 2 downloadable content!

Tom Clancy’s Ghost Recon 2 Xbox Downloadable Content #1

Available Now!

7 marzo 2005 – Ubisoft, una delle più grandi distributrici e sviluppatrici di giochi del mondo ha annunciato pggi il primo downloadable content (DLC) per Tom Clancy?s Ghost Recon 2 disponibile al download via Xbox Live!

Il DLC include:

.:. 3 MAPS:

These new maps will be available for many of the game types that shipped with Ghost Recon 2, plus the 2 new game types included in this package.

Train Yard Interior: This level focuses gameplay exclusively in the complex train station section of the Train Yard map. Shadowed areas with heavy cover contrasted by unforgiving well-lit open terrain will provide for an intense close-quarters combat experience. This map is great for small Squad or Solo games.

Train Yard Forest: Battle it out in the heavily wooded nighttime setting of the exterior forest from the Train Yard map. Keep to the shadows or brave the well-lit roadway to gain the advantage over an unsuspecting enemy. This map is particularly well suited for squad gametypes or larger solo games.

Railway Valley: This level concentrates on the furious action provided by the wooded groves and rocky outcropping in the large valley of the Railway map. Players will be able snipe approaching enemies from behind boulders or stealthily attack from tree-cover. This map is great for any size solo or squad gametype.

.:. 2 MODES:

These modes are available for play on most of the multiplayer maps that shipped with Ghost Recon 2.


In the Ghost Recon variant of the classic Capture the Flag gametype players will battle each other to capture and return a flag to their squad base. Each time the flag is secured at a team?s base they will score 100 points and the flag will be re-set back in the center of the map. Respawns are enabled to further intense action experience. Solid Squad tactics and strategy are a must to dominate in this gametype.


In the Assassination gametype squads are pitted against each other to defend or, alternatively, assassinate an AI officer. When the game starts one squad will be chosen to defend the officer while the other is charged will eliminating him. Scores are based off of how long the officer is kept alive or how long it takes to eliminate him. There are no respawns in this gametype so ever shot counts.

.:. 8 WEAPONS:

M8 Compact: The M8 Compact is a shortened version of the standard carbine. It is highly maneuverable, although less accurate than other versions.

MP5 SD: The MP4 is a popular submachine gun. This version incorporates a suppressor for quiet operation.

S9 SD Sniper: The S9 is an advanced marksman version of the G36 rifle. This version is suppressed and fires special subsonic ammo.

Mk 48 LMG: The Mk 48 LMG is an update to the Mk46, firing the more powerful 7.62 cartridge.

FAMAS G2: The bullpup FAMAS G2 is the standard infantry rifle of the French army. It is known for its high rate of fire.

FAMAS/M203S: This is a standard FAMAS G2 with an attached M203 launcher.

MSG-90: Used by the German Army, the MSG-90 is a powerful sniper platform based on the battle proven G3.

AS56 SA W: Designed to increase the capabilities of the M4, the AS56 is essentially a belt-fed M4, creating a compact SA W.

2 Skins:

New Ghosts Set with Digital Camo from the US Army.

New set of Korean enemies.

Easter Rappy su PSO Xbox

Arrivano anche sulla versione Xbox di Phantasty Star Online gli Easter Rappy.

Per trovarli basterà girovagare per il Temple e sperare che vengano fuori, il drop non è sempre sicuro ma in base all’ID aumenta la percentuale di drop, almeno in teoria… 😀

Informazioni sul drop