php 给段落添加空格的简单示例

前端之家收集整理的这篇文章主要介绍了php 给段落添加空格的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP给每个段落添加空格的代码感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * PHP给每个段落添加空格的代码
 *
 * @param 
 * @arrange 512-笔记网: jb51.cc
 **/
//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 ) );
}
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528492.html

猜你在找的PHP相关文章