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程序设计有所帮助。

相关文章

判断是否为指定长度内字符串的php函数

复制代码 代码如下: //———————————————————————————– // 函数名:CheckLengthBetween($C_char, $I_len1, $I_len2...

PHP 导出Excel示例分享

下载PHPExcel_1.8.0_doc.zip http://phpexcel.codeplex.com/,将解压后的文件夹里的Classes上传到网站的根目录下,Classes目录内...

PHP实现批量修改文件后缀名的方法

本文实例讲述了PHP实现批量修改文件后缀名的方法。分享给大家供大家参考。具体如下: /** * 批量修改文件后缀名 * @param $path 文件夹路径 * @param...

PHP array_multisort()函数的使用札记

函数  bool array_multisort ( array &$arr [, mixed $arg = SORT_ASC [, mixed $arg = SORT_REGULAR...

php 使用expat方式解析xml文件操作示例

本文实例讲述了php 使用expat方式解析xml文件操作。分享给大家供大家参考,具体如下:test.xml:<?xml version="1.0"&n...