• PHP Video Tutorials

PHP - Function Str Pad



Syntax

str_pad(string,length,pad_string,pad_type)

Definition and Usage

It is used to pads a string to a new length.

Return Values

It returns the padded string

Parameters

Sr.No Parameters & Description
1

String

It specifies the string to pad

2

length

It specifies the new string length

3

pad_string

It specifies the string to use for padding

4

pad_type

It specifies the what side to pad the string

Example

Try out the following example

<?php
   $input = "Tutorials point ";
   
   echo str_pad($input,18,":-)"); 
?>

This will produce following result −

Tutorials point:-)
php_function_reference.htm
Advertisements