Changeset 82546 in spip-zone


Ignore:
Timestamp:
May 17, 2014, 12:02:45 PM (5 years ago)
Author:
marcimat@…
Message:

Array_pad complete le tableau jusqu'à atteindre une certaine taille. Ici, on ajoute des 0 à droite du tableau jusqu'à son total sans ce soucier du nombre d'éléments qu'on a déjà.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/indexer/trunk/inc/sphinxql_to_array.php

    r82545 r82546  
    1717        $all = $sphinx->allfetsel($u);
    1818
     19        $total = intval($all['query']['meta']['total']);
     20
    1921        // pagination : rajouter $debut elements vides
    2022        if ($debut) $all['query']['docs'] = array_pad($all['query']['docs'], -$debut - count($all['query']['docs']), 0);
    2123
    22         $total = $all['query']['meta']['total'];
    23         var_dump($total);
    24         if ($total > count($all['query']['docs']))
    25                 $all['query']['docs'] = array_pad($all['query']['docs'], $total - count($all['query']['docs']), 0);
     24        if ($total > count($all['query']['docs'])) {
     25                $all['query']['docs'] = array_pad($all['query']['docs'], $total, 0);
     26        }
    2627
    2728        return $all;
Note: See TracChangeset for help on using the changeset viewer.