🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #497

Re: PHP:ordenamiento array

#497
From: Hector Vergara R.
Date: Sun, 25 May 2008 08:32
76 lines
3472 bytes
Tambien se puede usar la funci�n usort, a la cual le das como parametro el 
Array y un callback que compare los elementos de este

Un ejemplo:

<?php

$mailList = array(
  array('correo1.56', 'hotmail.com'),
  array('correo-mio', 'yeah.info'),
  array('mail', 'abc.def'),
  array('email', 'hotmail.com')
);

function sortAccounts($a, $b) {
  return strcmp($a[1], $b[1]);
}

usort($mailList, 'sortAccounts');

print_r($mailList);

?>

Saludos, H�ctor.

"Jos� Miguel Santib��ez" <jms.nospam@nivel5.cl> wrote in message 
news:Xns9AA6575ABDFjmsnews@201.238.250.229...
> En el cap�tulo anterior (news:g12ptu$oaa$1@news.nivel5.cl), "+mArkO+"
> <kitim@porta.com> dijo:
>
>> tengo un array llamado lista_correo
>>
>> Array
>> (
>>     [0] => Array([0] => correo1.56  [1] => hotmail.com)
>>     [1] => Array([0] => correo2       [1] => gmail.com)
>>     [2] => Array([0] => email           [1] => hotmail.com)
>>     [3] => Array([0] => correo_valido[1] => yahoo.com)
>>     [4] => Array([0] => correo-mio   [1] => yeah.info)
>>     [5] => Array([0] => yeahhhh       [1] => qmail.com)
>>     [6] => Array([0] => correo1m     [1] => gmail.com)
>>     [7] => Array([0] => mail            [1] => abc.def )
>>     [8] => Array([0] => jajaja           [1] => jejeje.jiji)
>>     [9] => Array([0] => mmmjsdhhf   [1] => hotmail.com)
>> )
>>
>> el asunto de esto es que deseo ordenarlo por servidor.
>>
>> Array
>> (
>>     [0] => Array( [0] => mail [1] => abc.def)
>>     [1] => Array( [0] => correo1m [1] => gmail.com)
>>     [2] => Array( [0] => correo2  [1] => gmail.com)
>>     [3] => Array( [0] => correo1.56 [1] => hotmail.com)
>>     [4] => Array( [0] => email [1] => hotmail.com)
>>     [5] => Array( [0] => mmmjsdhhf [1] => hotmail.com)
>>     [6] => Array( [0] => jajaja [1] => jejeje.jiji )
>>     [7] => Array( [0] => yeahhhh [1] => qmail.com)
>>     [8] => Array( [0] => correo_valido [1] => yahoo.com)
>>     [9] => Array( [0] => correo-mio [1] => yeah.info)
>> )
>>
>> existe alguna funcion que me permita decirle que ordene segun la 2
>> columna, es decir el servidor de correo
>>
>>
>>
>
> Mira en:
> http://cl.php.net/manual/es/function.array-multisort.php
>
> -- 
> Apoye a la campa�a de alfabetizaci�n y  |       Jose M. Santiba�ez A.
> ordenaci�n de las news, cada post en su |          <jms@nivel5.cl>
> lugar y el lugar exacto para cada post  |        <http://caos.cl/jms> 
Technical Details
Message-ID: <g1b86r$uu8$1@news.nivel5.cl>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!not-for-mail
References: <g12ptu$oaa$1@news.nivel5.cl> <Xns9AA6575ABDFjmsnews@201.238.250.229>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,4319aabd679d8580
X-Google-Attributes: gid1593cb,domainid0,public,usenet
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!not-for-mail
From: "Hector Vergara R." <hvergara_en@gmail.com>
Newsgroups: chile.comp.programacion
Subject: Re: PHP:ordenamiento array
Date: Sun, 25 May 2008 04:32:25 -0400
Organization: Varios
Lines: 78
Message-ID: <g1b86r$uu8$1@news.nivel5.cl>
References: <g12ptu$oaa$1@news.nivel5.cl> <Xns9AA6575ABDFjmsnews@201.238.250.229>
NNTP-Posting-Host: pc-150-216-47-190.cm.vtr.net
X-Trace: news.nivel5.cl 1211704347 31688 190.47.216.150 (25 May 2008 08:32:27 GMT)
X-Complaints-To: news@news.nivel5.cl
NNTP-Posting-Date: Sun, 25 May 2008 08:32:27 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original