Code To Create String With n Spaces - Php

Explain the code to function that fills a string with a given number of spaces in php?

Snippet Code


  
Rate this page :
  [ 0 votes]

The simple code which allows you to fill blank spaces by creating string.You can add space up to given number.Entered space should not exceed the string length. The code to fill number of spaces using php is given below.

<?php function space($str,$space) { $op = str_pad($str,$space," "); return $op; } $str = "Hello World"; $space = 30; echo space($str,$space); ?>

Tags


Ask Questions

Ask Question