Home >Backend Development >PHP Tutorial >How to add spaces to each paragraph in php, add spaces to paragraphs in php_PHP tutorial

How to add spaces to each paragraph in php, add spaces to paragraphs in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:02:031370browse

How to add spaces to each paragraph in php, add spaces to paragraphs in php

The example in this article describes how to add spaces to each paragraph in php. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
 //Prepends whitespace to each line of a string
 function white_space( $string, $whitespace )
 {
  //Create an array from the string, each key having one line
  $string = explode( PHP_EOL, $string );
  //Loop through the array and prepend the whitespace
  foreach( $string as $line => $text )
  {
   $string[ $line ] = $whitespace . $text;
  }
  //Return the string
  return( implode( PHP_EOL, $string ) );
 }
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/970986.htmlTechArticleHow to add spaces to each paragraph in php, add spaces to each paragraph in php. This article explains how to add spaces to each paragraph in php. Space method. Share it with everyone for your reference. The specific implementation method is as follows...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn