Formater un entier en PHP

Résolu
.Zoro. Messages postés 263 Date d'inscription   Statut Membre Dernière intervention   -  
.Zoro. Messages postés 263 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

est-ce que quelqu'un sait comment manipuler les entiers (ou les float aussi)
de maniere a forcer leurs affichage sur 2 chifres

1 => 01
5 => 05
11 => 11

merci
A voir également:

2 réponses

jisisv Messages postés 3645 Date d'inscription   Statut Modérateur Dernière intervention   934
 
Regarde ici
https://www.php.net/manual/fr/function.sprintf.php

exemples
johand@osiris:~/public_html$ cat format.php  
<?php 
printf("Entier: %03d\n", 17); 
printf("Flottant: %08.3f\n", 3.1415926); 
?> 
johand@osiris:~/public_html$ php format.php  
Entier: 017 
Flottant: 0003.142 

Gates gave ^H sold you the windows.
GNU gave us the whole house.(Alexandrin)
0
.Zoro. Messages postés 263 Date d'inscription   Statut Membre Dernière intervention   33
 
merci jisisv
cette fonction correspond a ce que je cherchais
0