note 98204 deleted from function.wordwrap by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: baran_rafal at wp dot pl 

----

main version function a 'wordwrap'

<?php
/*
		* @param int $ile_lini
		* @param int $le_znakow_w_lini
		* $param str $ogonek
		* $param str $text
		 */
		public static function _wordwrap($ile_linii, $ile_znakow_w_lini, $ogonek, $text)
		{
			$dlugosc = strlen($text);
			$text = wordwrap($text, $ile_znakow_w_lini, "\n", true);
			if($dlugosc > $ile_znakow_w_lini)
			{
				$text_A = explode("\n", $text);
				$new_text = '';
				for($i=0;$i<$ile_linii;$i++)
				{
					$new_text .= "\n" . $text_A[$i];
				}
				$dlugosc_ostatniego_ciagu = strlen($text_A[$ile_linii-1]);
				if($dlugosc_ostatniego_ciagu<=$ile_znakow_w_lini-3)
				{
					if($dlugosc > $ile_linii*$ile_znakow_w_lini)
					{
						$new_text = $new_text.'...';
					}
					elseif($text_A[$ile_linii] != '')
					{
						$new_text = $new_text.'...';
					}
				}
				else
				{
					$dlugosc > $ile_linii*$ile_znakow_w_lini ? $new_text = substr($new_text, 0, -3).'...' : '';
				}
			}
			return $new_text;
		}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.