Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
zero_fill
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
<?php /* * zero_fill * * Rellena con ceros a la izquierda * * @param $valor valor a rellenar * @param $long longitud total del valor * @return valor rellenado */ function zero_fill ($valor, $long = 0) { return str_pad($valor, $long, '0', STR_PAD_LEFT); } //Ejemplos de uso echo zero_fill(5, 4)."\n"; echo zero_fill(47,0)."\n"; echo zero_fill(1000)."\n"; echo zero_fill(1000,50)."\n"; echo zero_fill(23,-1000)."\n"; ?>
[
+
]
Show input
Absolute running time: 0.14 sec, cpu time: 0.01 sec, memory peak: 8 Mb, absolute service time: 0,14 sec
edit mode
|
history
0005 47 1000 00000000000000000000000000000000000000000000001000 23