Split a string and store into an array

This PHP script code is for split a string into the specified length and store it into an array. Here we are using a form to enter the string to split , length at which split process and the cut mode . In normal cut modes split wont happen in the middle of a single word , in strict mode split will happen strictly even in the middle of a single word.

<html>
<head>
</head>
<body>
<form name="split" action="" method="post">
Enter the string to Split
<input type="text" name="text1" /><br />
Enter the character length to split:<input type="text" name="len1" /><br />
Cut Mode;<select name="cut">
<option value=0 t>Normal Cut</option>
<option value=1>Strict Cut</option>
</select><br>
<input type="submit" value="split" name="btnsubmit" />

</form>
<?php
if(isset($_POST['btnsubmit']))
{
$text=$_POST['text1'];
$len1=$_POST['len1'];
$mode=$_POST['cut'];
//echo "Original String ".$text;
//$count= strlen($text);
$newtext = wordwrap($text, $len1, "<***>",$mode);
$result=explode('<***>', $newtext);
$count= count($result);
$i=0;
while ($i<$count)
{
echo "String ".$i." is : <b>".$result[$i]."</b><br>";
$i=$i+1;
}
}
?>
</body>
</html>
Share
Share
Share