PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

php 怎么设置空格

藏色散人
藏色散人 原创
2021-11-15 09:27:00 6336浏览

php设置空格的方法:1、创建一个php示例文件;2、通过“function white_space( $string, $whitespace ){...}”方法设置空格即可。

本文操作环境:windows7系统、PHP7.1版、DELL G3电脑

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视频教程

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。