龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

white php给每个段落添加空格的代码

时间:2014-06-06 15:15来源:网络整理 作者:网络 点击:
分享到:
php给每个段落添加空格的代码 [代码片段(18行)]
<?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 ) );
  }
?>

精彩图集

赞助商链接