php给每个段落添加空格的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了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程序设计有所帮助。

相关文章

CodeIgniter图像处理类的深入解析

image.php 复制代码 代码如下:<?phpclass Image extends Controller {    function Image...

php基本函数汇总

1.统计数组元素个数 $arr = array( '1011,1003,1008,1001,1000,1004,1012', '1009', '1011,1003...

php 获得汉字拼音首字母的函数

php获取汉字拼音的第一个字母复制代码 代码如下:<?php function getinitial($str) { $asc=ord(substr($str,0,1)); if...

解析htaccess伪静态的规则

利用htaccess文件可以很好的进行站点伪静态,并且形成的目标地址与真正的静态页面几乎一模一样,如wangqu.html等,伪静态可以非常好的结合SEO来提高站点的排名,并且也能给人一...

重新封装zend_soap实现http连接安全认证的php代码

复制代码 代码如下: <?php class MyFramework_Soap_server extends Zend_Soap_Server { protected $_logi...