src/MvcCore/Ext/View/Helpers/LineBreaksHelper.php
public function LineBreaks ($text, $lang = "") {
		$this->text = $text;
		$word = "";
		$lang = $lang ? $lang : $this->lang;
		list($weekWords, $units, $shortcuts) = $this->getWeekWordsUnitsAndShortcuts($lang);

		// if there are one or more tab chars in source text, convert them into single space
		$this->text = preg_replace("#\t+#mu", " ", $this->text);

		// if there are one or more space chars in source text, convert them into single space
		$this->text = preg_replace("#[ ]{2,}#mu", " ", $this->text);
		// for each week word
		for ($i = 0, $l = count($weekWords); $i < $l; $i += 1) {
			// load current week word into $word variable
			$word = $weekWords[$i];
			// process source text with current week word
			$this->processWeakWord($word);
			// convert first week word character into upper case (first word in sentence)
			$word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1);
			// process source text with current week word with first upper cased char
			$this->processWeakWord($word);
		}

		// for each unit(s), where is white space char before and any number before that white space char:
		for ($i = 0, $l = count($units); $i < $l; $i += 1) {
			// load current unit into $word variable
			$word = $units[$i];
			// create regular expression pattern to search for unit(s), where is white space char before
			// and any number before that white space char
			$regExp = "#([0-9])\\s(" . $word . ")#mu";
			// process replacement for all founded white spaces into fixed space html entity in source text
			$this->text = preg_replace(
				$regExp,
				"$1&nbsp;$2",
				$this->text
			);
		}

		// for all special shortcuts - remove all line breaking white spaces
		foreach ($shortcuts as $sourceShortcut => $targetShortcut) {
			$this->text = str_replace($sourceShortcut, $targetShortcut, $this->text);
		}

		// for all decimals, where is space between them:
		// example: 9 999 999 -> 9&nbsp;999&nbsp;999
		$this->text = preg_replace("#([0-9])\s([0-9])#", "$1&nbsp;$2", $this->text);

		return $this->text;
	}
public function LineBreaks ($text, $lang = "") {
		$this->text = $text;
		$word = "";
		$lang = $lang ? $lang : $this->lang;
		list($weekWords, $units, $shortcuts) = $this->getWeekWordsUnitsAndShortcuts($lang);

		// if there are one or more tab chars in source text, convert them into single space
		$this->text = preg_replace("#\t+#mu", " ", $this->text);

		// if there are one or more space chars in source text, convert them into single space
		$this->text = preg_replace("#[ ]{2,}#mu", " ", $this->text);
		// for each week word
		for ($i = 0, $l = count($weekWords); $i < $l; $i += 1) {
			// load current week word into $word variable
			$word = $weekWords[$i];
			// process source text with current week word
			$this->processWeakWord($word);
			// convert first week word character into upper case (first word in sentence)
			$word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1);
			// process source text with current week word with first upper cased char
			$this->processWeakWord($word);
		}

		// for each unit(s), where is white space char before and any number before that white space char:
		for ($i = 0, $l = count($units); $i < $l; $i += 1) {
			// load current unit into $word variable
			$word = $units[$i];
			// create regular expression pattern to search for unit(s), where is white space char before
			// and any number before that white space char
			$regExp = "#([0-9])\\s(" . $word . ")#mu";
			// process replacement for all founded white spaces into fixed space html entity in source text
			$this->text = preg_replace(
				$regExp,
				"$1&nbsp;$2",
				$this->text
			);
		}

		// for all special shortcuts - remove all line breaking white spaces
		foreach ($shortcuts as $sourceShortcut => $targetShortcut) {
			$this->text = str_replace($sourceShortcut, $targetShortcut, $this->text);
		}

		// for all decimals, where is space between them:
		// example: 9 999 999 -> 9&nbsp;999&nbsp;999
		$this->text = preg_replace("#([0-9])\s([0-9])#", "$1&nbsp;$2", $this->text);

		return $this->text;
	}
public function LineBreaks ( $ text , $ lang = "" ) { $ this -> text = $ text ; $ word = "" ; $ lang = $ lang ? $ lang : $ this -> lang ; list ( $ weekWords , $ units , $ shortcuts ) = $ this -> getWeekWordsUnitsAndShortcuts ( $ lang ) ; // if there are one or more tab chars in source text, convert them into single space $ this -> text = preg_replace ( "#\t+#mu" , " " , $ this -> text ) ; // if there are one or more space chars in source text, convert them into single space $ this -> text = preg_replace ( "#[ ]{2,}#mu" , " " , $ this -> text ) ; // for each week word for ( $ i = 0 , $ l = count ( $ weekWords ) ; $ i < $ l ; $ i += 1 ) { // load current week word into $word variable $ word = $ weekWords [ $ i ] ; // process source text with current week word $ this -> processWeakWord ( $ word ) ; // convert first week word character into upper case (first word in sentence) $ word = mb_strtoupper ( mb_substr ( $ word , 0 , 1 ) ) . mb_substr ( $ word , 1 ) ; // process source text with current week word with first upper cased char $ this -> processWeakWord ( $ word ) ; } // for each unit(s), where is white space char before and any number before that white space char: for ( $ i = 0 , $ l = count ( $ units ) ; $ i < $ l ; $ i += 1 ) { // load current unit into $word variable $ word = $ units [ $ i ] ; // create regular expression pattern to search for unit(s), where is white space char before // and any number before that white space char $ regExp = "#([0-9])\\s(" . $ word . ")#mu" ; // process replacement for all founded white spaces into fixed space html entity in source text $ this -> text = preg_replace ( $ regExp , "$1&nbsp;$2" , $ this -> text ) ; } // for all special shortcuts - remove all line breaking white spaces foreach ( $ shortcuts as $ sourceShortcut => $ targetShortcut ) { $ this -> text = str_replace ( $ sourceShortcut , $ targetShortcut , $ this -> text ) ; } // for all decimals, where is space between them: // example: 9 999 999 -> 9&nbsp;999&nbsp;999 $ this -> text = preg_replace ( "#([0-9])\s([0-9])#" , "$1&nbsp;$2" , $ this -> text ) ; return $ this -> text ; }
Process configured weak words and units and place HTML space entity
where is necessary to not line break source text where it's not wanted.
@param string $text source text
@param string $lang optional, international language code
@return string
Process configured weak words and units and place HTML space entity where is necessary to not line break source text where it s not wanted .