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

 2025-01-17  阅读 462  评论 8  点赞 343

摘要:本文实例讲述了php给每个段落添加空格的方法。分享给大家供大家参考。具体实现方法如下: $text ) { $string[ $line ] = $whitespace . $text; } //return the string return( implode( php_eol, $string ) ); } ?> 希望本文所述对大家的php程序设计有所帮助。

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


标签:phpphp教程

评论列表:

  •   xixi2
     发布于 1月前回复该评论
  • 写的很不错,学到了!
显示更多评论

发表评论:

管理员

承接各种程序开发,外贸网站代运营,外贸网站建设等项目
  • 内容2462
  • 积分67666
  • 金币90666

Copyright © 2024 LS'Blog-保定PHP程序员老宋个人博客 Inc. 保留所有权利。 Powered by LS'blog 3.0.3

页面耗时0.0273秒, 内存占用1.93 MB, 访问数据库30次

冀ICP备19034377号