php給每個(gè)段落添加空格的方法
更新時(shí)間:2015年03月20日 11:43:21 作者:work24
這篇文章主要介紹了php給每個(gè)段落添加空格的方法,涉及PHP_EOL變量及數(shù)組與字符串的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php給每個(gè)段落添加空格的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
<?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程序設(shè)計(jì)有所幫助。
相關(guān)文章
PHP設(shè)計(jì)模式之模板方法模式實(shí)例淺析
這篇文章主要介紹了PHP設(shè)計(jì)模式之模板方法模式,結(jié)合實(shí)例形式簡單分析了php設(shè)計(jì)模式中模板方法模式的概念、原理、定義、使用方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2018-12-12
淺析PHP substr,mb_substr以及mb_strcut的區(qū)別和用法
本篇文章是對PHP中的substr,mb_substr以及mb_strcut區(qū)別和用法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
PHP中array_map與array_column之間的關(guān)系分析
這篇文章主要介紹了PHP中array_map與array_column之間的關(guān)系分析,對于PHP初學(xué)者來說是比較實(shí)用的概念,需要的朋友可以參考下2014-08-08
PHP使用緩存即時(shí)輸出內(nèi)容(output buffering)的方法
這篇文章主要介紹了PHP使用緩存即時(shí)輸出內(nèi)容(output buffering)的方法,實(shí)例分析了php緩存輸出的相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08

