Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created August 29, 2013 09:19
Show Gist options
  • Save phpfiddle/6375967 to your computer and use it in GitHub Desktop.
Save phpfiddle/6375967 to your computer and use it in GitHub Desktop.
stripara140
<?php
function stripeWords($para){
$text=explode(' ',$para);
foreach($text as $word)
{
$length=strlen($word);
if($length >=4)
{
echo $word;
echo " ";
}
}
// Implement the logic for remove the words which length have less than 4 and return the result as an array
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
if(isset($_POST['para'])){
$para = stripeWords($_POST['para']);
?>
<h3>Striped Paragraph</h3>
<?php print_r($para); ?>
<?php
} else{
?>
<h3>My form</h3>
<form method="post">
<label>Paragraph</label> <textarea name="para"></textarea><br />
<button id="mysubmit" type="submit">Submit</button><br /><br />
</form>
<?php
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment