<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * Description of TextArrangement * * @author 一基 */ class TextArrangement { private $row; //行数 private $sentence; //テキストエリアの値を取得 private $cr; //改行コード置換用配列 private $sentenceArray; //テキストエリアの値を配列に置き換えたもの //コンストラクタ function __construct($sentence, $row) { $this->sentence = trim($sentence); $this->row = $row + 1; $this->cr = array("\r\n", "\r"); } public function createSentenceArray() { //改行コードの変換 $this->sentence = str_replace("\\", "", $this->sentence); $this->sentence = str_replace($this->cr, "\n", $this->sentence); //改行コードで分割 $this->sentenceArray = explode("\n", $this->sentence); //最後の行が空白かどうか if (($this->sentenceArray[$this->row - 1] == null) && ($this->row >= 1)) { $this->row--; } } public function getRow() { return $this->row; } public function getSentenceArray() { return $this->sentenceArray; } }