note 41080 added to function.split

From: Date: Mon, 29 Mar 2004 19:41:08 +0000
Subject: note 41080 added to function.split
Groups: php.notes 
Request: Send a blank email to php-notes+get-67337@lists.php.net to get a copy of this message
I created the following to parse my user input... Let's say someone adds a comment to my comment system... I want them to be able to have some newlines, but they could be mallicious and try and throw like 40 newlines in there... That could look real ugly... This way I can set a maximum of newlines a user can enter. :) <?php $MaxNewLines = 5; $Message = str_replace(chr(13), "<br />", $Message); $MessageArray = split("<br />", $Message, $MaxNewLines); $Message = ""; $u=0; do { $Message.=$MessageArray[$u].'<br />'; $u++; } while($u<($MaxNewLines-1)); $Message.=str_replace("<br />"," ",$MessageArray[$u]); ?> -Tim http://www.alphibia.com ---- Manual Page -- http://www.php.net/manual/en/function.split.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41080 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41080&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41080&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67337) next »