Formater un entier en PHP

Résolu
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

2 réponses

  1. merci jisisv
    cette fonction correspond a ce que je cherchais
    1. Modérateur
      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)