plugins - How to add character to content of post? -


in per posts, there "oo/x/".

how add "0" before "x" if length(x) <10 ?

example:

x=12345678 ; length(x) = 8, add "00" before x ===> x=0012345678

x=1234567 ; length(x) = 7, add "000" before x ===> x=0001234567

x=123456789 ; length(x) = 9, add "0" before x ===> x=0123456789

do understand ? sorry poor english ! thank !

in ansi c:

#include <stdio.h>  int main() {    int x = 12345678;    printf("x = %010d\n", x);    return 0; } 

note %010d, % format specifier replaced following argument, 0 being flag pads 0's, , maximum number of 0's.

read more here - printf()

if java, can using system.out.printf(); in same way.

edit: it's clear on problem domain lies (in case wordpress), can use php.

see following barebones example using sprintf() in php:

<?php    // ...    $x = 12345678;    $yourstring = sprintf(nl2br("x = %010d\n"), $x);     // ...     echo $yourstring; ?> 

how printing out values depends on how you're retrieving information , layout, simple example answers question.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -