Last Updated: March 31, 2021
·
8.281K
· silvercorp

Anteponer ceros con PHP

/* En total deben ser 5 dígitos, los faltantes serán reemplazados por el        número cero */

$numero = 10;

str_pad($numero, 5, "0", STR_PAD_LEFT);

2 Responses
Add your response

Pensar que hasta ahora lo hacia con un
$codigo = '';

$codigo = $codigo + $x;
todo eso dentro de un ciclo con varios if's anidados xD

over 1 year ago ·

Gracias por su aporte

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside