这篇文章将为大家详细讲解有关php如何给每个段落添加空格,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
具体实现方法如下:
<?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 ) );
}
?>关于“php如何给每个段落添加空格”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。