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' ) );

https://stackoverflow.com/questions/2699086/how-to-sort-multi-dimensional-array-by-value

Configurare php.ini

Quando si lavora in un ambiente di test mi torna sempre utile aumentare certi parametri. Solitamente:

post_max_size = 256M

upload_max_filesize = 128M

memory_limit = 512M

max_execution_time = 300

max_input_time = 120

max_input_vars = 1500

Manutenzione straordinaria

Causa urgente intervento sul server il sito non sarà raggiungibile domani mercoledì 5 dicembre.
Orario intervento:
Start: December 5, 2018 8:30:00 AM CET
End: December 5, 2018 10:00:00 AM CET (expected)

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(
'"'.$this->ripartizioneGeografica.'"',
'"'.$this->codice.'"',
'"'.$this->nome.'"'
);
$strValori = implode(',', $arrValori);
$sql="INSERT INTO regioni(ripartizione_geografica, codice, nome) VALUES (".$strValori.");\n";
return $sql;
}
}

Continue reading

Respinte un sacco di cause contro CoH

NCsoft ha avuto qualche grattacapo con Marvel a quanto sembra riguardo ai diritti d’autore del suo MMORPG “City of Heroes”.

Ma sembra che le accuse siano state respinte dal giudice R. Gary Klausner.
Ecco la news:
Comic book giant Marvel’s legal action against City of Heroes publisher NCsoft Corporation and developer Cryptic Studios has taken a heavy blow this week after a US district court judge in Los Angeles dismissed a number of key claims.

Judge R. Gary Klausner dismissed more than half of Marvel’s claims, NCsoft revealed in a statement this afternoon, including Marvel’s claims that the defendants directly infringed Marvel’s registered trademarks.

Judge Klausner also agreed with the defendants that some of Marvel’s allegations and exhibits should be stricken as “false and sham” because they were not actually created by users of the game but by Marvel itself.

He further dismissed Marvel’s claim for a judicial declaration that defendants are not an online service provider under the Digital Millennium Copyright Act, which offers a degree of protection in such cases.

Furthermore, he dismissed these claims without leave to amend, meaning Marvel cannot file them again.

The court also cited a 1984 Supreme Court case which holds that the sale of VCRs does not violate copyright law, noting, “It is uncontested that Defendants’ game has a substantial non-infringing use. Generally the sale of products with substantial non-infringing uses does not evoke liability for contributory copyright infringement.”

In other words, the court is satisfied that City of Heroes is primarily a massively multiplayer online role-playing game and not a copyright infringement tool.

While certain claims were allowed to survive the motion to dismiss, the defendants have 10 days in which to answer and dispute them and asset legal defences, and NCsoft and Cryptic Studios are confident of overcoming them.

This latest news of the case comes after the defendants issued an impassioned plea in their motion to dismiss defending the creative freedoms of artists and declaring that if its character creation tools were deemed illegal, so should be the pencil and other creative implements.

Gods and Heroes, MMORPG in progress

Perpetual Entertainment, la celebre compagnia sviluppatrice del futuro MMORPG ambientato nell’universo di Star Trek, ha annunciato oggi lo sviluppo di un nuovo gioco di ruolo massive multiplayer online (per rimanere in tema) intitolato Gods and Heroes: Rome Rising.

Il titolo è ambientato nella Roma antica del 300 A.C. dove i giocatori si ritroveranno a combattere con diversi tipi di nemici, compresi i mostri della mitologia. I giocatori saranno assistiti da una delle dodici divinità presenti nel gioco, i cui poteri potranno essere controllati dagli stessi giocatori.

Perpetual Entertainment website

ecco qualche screen del gioco:

Fonte: Iama

SONY promette vita facile per lo sviluppatore

A quanto pare, pur se non è arrivata ad elencare prodotti come MS ne ha avuto società che hanno “garantito” il loro supporto, Sony è stata chiara nell’indicare che lavorare su PS3 sarà molto più facile che non su PS2.

E la cosa non può che far felici indicando che la qualità media delle produzioni su PS3 si alzerà rispetto a PS2.

Ecco l’articolo.

Vale la pena anche leggere la parte in neretto che chiaramente mostra quanto i chip non siano fatti di magia e quanto il Cell, per quanto molto diverso, concettualmente non è così lontano da un IBM Power Chip.

Riconfermando così proprio per bocca di Sony un articolo già discusso sul forum di Tekwar

GDC: Sony promises developers an easy ride on PS3

Market leader pledges to avoid the mistakes of the last generation.

Game development for Sony’s next-generation PlayStation will be made significantly easier by the availability of high-level, familiar tools and interfaces for the platform from the outset, SCEA dev relations manager Mark DeLoura has promised.

Speaking at one of the first ever open sessions on PlayStation 3 development, DeLoura focused on Sony’s efforts to ensure that the platform is easy to get up and running on – addressing common concerns that the new Cell architecture may be difficult for developers to get to grips with.

The shadow of the difficulties developers faced with PlayStation 2 still looms over Sony, to the extent that even Microsoft’s J Allard had a pop at the company’s developer-unfriendly track record in his keynote address on Wednesday morning.

The PlayStation Portable’s comprehensive set of tools and APIs has largely been well-received by developers, but for PlayStation 3, the company plans to go even further – adopting a number of familiar industry standard systems that will give game creators a running start on the platform.

DeLoura told a packed audience that Sony is working with the consortium behind well-known PC graphics interface standard OpenGL to create a specialised version of the library which is optimised for interactive games, by stripping out much of the unnecessary bloat in the library.

The second part of the firm’s graphics software will be Cg, a high-level language created by NVIDIA for programming shaders to create advanced graphical effects, which is rapidly becoming the standard way to build these effects on the PC platform.

In terms of the Cell microprocessor itself, it would be difficult for any tool to fully mask the complexity of moving to a multi-processor architecture – a problem which developers on Microsoft’s Xenon platform will also face – with SCEA research director describing the task of making all the processing units work together as being similar to writing music for an orchestra.

However, Sony has at least pledged that the chip will be easy to control with C code, rather than requiring the hand-coding of large blocks of low-level assembler – one of the major difficulties of PlayStation 2 development, which tripped many projects up in the early days of the platform before coders began to specialise in that field.

Sony’s announcements served as a timely rebuttal to J Allard’s comments only a few hours before, and suggest that the company is taking the question of developer support extremely seriously with PlayStation 3. The news was welcomed by developers at the show, but didn’t seem to come as a surprise to many.

“The next PlayStation is basically using a PC style graphics part, and Cell is basically an IBM Power chip with some extra pipelines,” one US developer commented after the presentation. “It’s not that different to Microsoft’s box – we think it’s a bit more powerful, but the basic hardware is kind of similar. It makes sense that both of them will have good tools this time around. It won’t be like last generation when Xbox was a coder’s friend and PS2 was a nightmare. Sony won’t let that happen.”

Sony also revealed that it is working closely with the creators of key development tools to build a standard format for storing game assets, called Collada, which will be based on the XML specification and will allow assets to be easily ported between projects and tools.

Fonte: McValdemar (www.andtek.org)

Revolution retrocompatibile

In questi giorni nintendo dà molto a parlare di sè, prima se ne esce con una notizia di non retro compatibilità e invece oggi è proprio il presidente Iwata a confermare la notizia, la prossima console Nintendo sarà retrocompatibile.

Potete vedere la news di IGN qui di seguito con la parte importante evidenziata in grassetto:

Nintendo president Satoru Iwata delivered his keynote speech at the Game Developers Conference in San Francisco on Thursday. The company head outlined the publisher’s philosophies in regard to its next-generation console, which is codenamed Revolution. Iwata once more reiterated that while cutting edge graphics and audio are to be expected, Nintendo hopes to deliver a new gaming dynamic that will enhance the way players enjoy its software.

However, Iwata also announced Nintendo’s two major hardware partners for Revolution, both previously rumored to be working on the console and both industry stand-outs. IBM is deep in development with the CPU that will provide the processing power of the machine. The chip is codenamed “Broadway,” according to Nintendo. Meanwhile, ATI, which developed the GameCube’s graphics chip, is underway with GPU for Revolution. The chip is codenamed “Hollywood,” according to Nintendo.
Iwata explained the reasoning behind each codename. The CPU is called Broadway because, according to the executive, “Broadway is the capital of movie entertainment.” Meanwhile, Iwata said that the GPU’s name stems from the fact that “Hollywood is the capital of movie entertainment.” He added: “With Revolution, we are determined to create the new capital of interactive entertainment.”

“We’re excited to be developing the graphics chip set for Revolution, which continues our longstanding relationship with Nintendo,” explained Dave Orton, ATI Technologies’ president and chief executive officer. “As the leading graphics provider, ATI is committed to delivering exceptional visual performance that enables consumers to interact with new and visually compelling digital worlds. ATI is proud to support Nintendo’s innovative contributions to gaming.”

Nintendo president Satoru Iwata

Iwata also announced that Revolution would feature backward compatibility with GameCube, which means that consumers will be able to play GCN software on the next console.

In addition, the Nintendo president said that Revolution would be Wi-Fi compatible out of the box. The revelation goes hand-in-hand with the company’s newly announced DS online network, which enables owners of the handheld to connect to the Internet wirelessly and play against each other.

The publisher’s leader reassured attendees that Nintendo would be counting on third parties to support Revolution
. “We will be expanding our development reach,” he stated. “Some of these [future] games will come from larger internal development teams. Some from the kinds of relationships we’ve formed with third parties over the years.”

He indicated that Revolution, like GameCube, would be designed to appeal to development studios regardless of how fundamentally changed the console itself might prove to be. “Even though the game experience will be far different on Revolution, developing for it will be quite familiar,” he said.

Finally, Iwata introduced a brand new trailer for the anticipated GameCube title The Legend of Zelda. Naturally, onlookers were blown away.

“This is Nintendo’s plan: make our existing game world better,” Iwata said. “For us, this is a passion. This is a mission of adventure,” Iwata explained.

The Nintendo head promised more details on Revolution and the DS wireless network at the Electronics Entertainment Expo 2005, which kicks off this May in Los Angeles.

IGN’s DS sister site has full details on all the Nintendo DS related announcements made Thursday.