php 怎麼設定空格

藏色散人
發布: 2023-03-13 20:12:02
原創
6502 人瀏覽過

php設定空格的方法:1、建立一個PHP範例檔案;2、透過「function white_space( $string, $whitespace ){...}」方法設定空格即可。

php 怎麼設定空格

本文操作環境: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影片教學

以上是php 怎麼設定空格的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!