6.95.53 str_pad[ Exemples avec str_pad ] PHP 4 Description
string str_pad(string input ,int pad_length ,[string pad_string ],[int pad_type ])
str_pad complète la chaîne
input à droite, à gauche ou dans les
deux directions, avec pad_string jusqu'à la
taille de pad_length. Si pad_string
n'est pas fourni, input est complété avec
des espaces. Sinon, il est complété avec
pad_string.
pad_type peut prendre les valeurs de
STR_PAD_RIGHT, STR_PAD_LEFT, ou STR_PAD_BOTH. Si pad_type
n'est pas spécifiée, cela vaut STR_PAD_RIGHT.
Si pad_length est négative ou
inférieure à la taille courante de la chaîne
input, aucun complément n'est ajouté.
Exemple avec str_pad |
<?php $input = "Paris"; print str_pad($input, 10); // produces "Paris " print str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Paris" print str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Paris___" ?>
|
|