0

As I can make an ordered descending by the query field bytes each IP. This is my array contains other fields as refered or other browsers ....

[_id] => MongoId Object (
    [$id] => 528e6004b0a4191f698b4567
)
[FECHA] =>.........
[IP] => Array (
    [0] => Array (
        [Ip] => 172.17.10.
        [conexiones] => 71
        [bytes] => 122.75 KB
        [media] => 1770.338
    )
    [1] => Array (
        [Ip] => 192.168.6.145
        [conexiones] => 79
        [bytes] => 692.51 KB
        [media] => 8976.3164
    )
    [2] => Array (
        [Ip] => 172.17.108.3
        [conexiones] => 2
        [bytes] => 4.48 KB
        [media] => 2294.5
    )
    [3] => Array (
        [Ip] => 192.168.200.50
        [conexiones] => 123
        [bytes] => 6.10 MB
        [media] => 52004.699186992
...............

This is my code:

$Filtro="IP";

 $c = $collection->find(array('FECHA' => $Fecha), array($Filtro));
        $cont = 1;



while ($c->hasNext()) {
        $metodo = $c->getNext();           
        foreach ($metodo[$Filtro] as $f) {                
            ?>
            <tr>
                <td><?= $cont++ ?></td>
                <td><?= $f[$Filtro] ?></td>
                <td><?= $f['conexiones'] ?></td>
                <td><?= $f['bytes'] ?></td>
                <td><?= $f['media'] ?></td></tr>

            <?
        }
    }

Just shows me all data but unsorted. thanks

  • The usort documentation page has numerous functions for associative sort, but here is a SO question on it too: http://stackoverflow.com/questions/2699086/sort-multidimensional-array-by-value-2 – Sammaye Nov 22 '13 at 09:14
  • thanks @Sammaye, I used the array_multisort() function, that was my solution!! thanks! – Ma Angeles Lola Zaragoza Nov 24 '13 at 12:29

0 Answers0