This article mainly introduces the method of adding spaces to each paragraph in PHP, involving PHP_EOL variables and operation skills of arrays and strings. It has certain reference value. Friends in need can refer to this article
The example describes how to add spaces to each paragraph in PHP. The specific implementation method is as follows:
<?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 ) ); } ?>
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's learning.
Related recommendations:
Principles and usage of encryption and decryption in php
How to format phone numbers using regular expressions in php
php method to shut down the computer using a mobile phone
The above is the detailed content of How to add spaces to each paragraph in php. For more information, please follow other related articles on the PHP Chinese website!