php给每个段落添加空格的方法
更新时间:2015年03月20日 11:43:21 作者:work24
这篇文章主要介绍了php给每个段落添加空格的方法,涉及PHP_EOL变量及数组与字符串的操作技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了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程序设计有所帮助。
相关文章
浅析PHP substr,mb_substr以及mb_strcut的区别和用法
本篇文章是对PHP中的substr,mb_substr以及mb_strcut区别和用法进行了详细的分析介绍,需要的朋友参考下2013-06-06
PHP中array_map与array_column之间的关系分析
这篇文章主要介绍了PHP中array_map与array_column之间的关系分析,对于PHP初学者来说是比较实用的概念,需要的朋友可以参考下2014-08-08
PHP使用缓存即时输出内容(output buffering)的方法
这篇文章主要介绍了PHP使用缓存即时输出内容(output buffering)的方法,实例分析了php缓存输出的相关使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下2015-08-08


最新评论