array_multisort
<<<
array_pad array_pop
>>>

7.2 Tableaux
7 Index des fonctions
 Manuel PHP

. Introduction
. Pré-requis
. Installation
. Configuration à l'exécution
. Types de ressources
. Constantes prédefinies
. Voir aussi
. array_change_key_case
. array_chunk
. array_combine
. array_count_values
. array_diff_assoc
. array_diff
. array_fill
. array_filter
. array_flip
. array_intersect_assoc
. array_intersect
. array_key_exists
. array_keys
. array_map
. array_merge_recursive
. array_merge
. array_multisort
->array_pad
. array_pop
. array_push
. array_rand
. array_reduce
. array_reverse
. array_search
. array_shift
. array_slice
. array_splice
. array_sum
. array_unique
. array_unshift
. array_values
. array_walk
. array
. arsort
. asort
. compact
. count
. current
. each
. end
. extract
. in_array
. key
. krsort
. ksort
. list
. natcasesort
. natsort
. next
. pos
. prev
. range
. reset
. rsort
. shuffle
. sizeof
. sort
. uasort
. uksort
. usort

7.2.25 array_pad() Complète un tableau jusqu'à la longueur spécifiée, avec une valeur.

[ Exemples avec array_pad ]   PHP 4

array  array_pad ( array   input , int   pad_size , mixed   pad_value )

array_pad retourne une copie du tableau input complété jusqu'à la taille de pad_size avec la valeur pad_value . Si pad_size est positif, alors le tableau est complété à droite, s'il est négatif, il est complété à gauche. Si la valeur absolue de pad_size est plus petite que la taille du tableau input , alors le tableau n'est pas complété.

Exemple avec array_pad

<?php
  $input
= array(12, 10, 9);
  
$result = array_pad($input, 5, 0);
// Le résultat est array (12, 10, 9, 0, 0)
  
$result = array_pad($input, -7, -1);
// Le résultat est array (-1, -1, -1, -1, 12, 10, 9)
  
$result = array_pad($input, 2, "noop");
// pas complété
?>

Voir aussi array_fill et range .

<< array_pad >>
array_multisort Tableaux array_pop