Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.



Returns a lengthened version of the input string.


input|pad( length [, padding ] )


length integer The desired length of the string. Yes.
padding character Custom character to be used for padding. No.


A padded version of the input string.


This operator makes sure that the input string is at least "length" characters long by inserting extra characters at the end. It is possible to specify a custom character using the "padding" parameter (default is space). The operator returns a padded version of the input string.


Example 1

{'Too short!'|pad( 15 )}

The following string will be produced: "Too short! ".

Example 2

{'Too short!'|pad( 16, '-' )}

The following string will be produced: "Too short!------".

Balazs Halasy (05/02/2004 10:58 am)

Balazs Halasy (04/05/2005 2:44 pm)


  • How to pad left?

    Is there a way to left-pad a string without having to reverse|pad|reverse it ?
  • How to pad left .. I found out how

    This requires some lateral thinking:

    for example, to pad a 0-99 $number to 00-99:

    0|pad(2, $number)

    I don't know what happens if $number is over 2 digits tho'. didn't try it.