redarrow Posted March 16, 2007 Share Posted March 16, 2007 Advance thank you. currently the function wordwrap is used to make a brake afther 47 charecters and the substr function lets only 200 charecters to be seen on the page. now what i need is a way to tell if the user enter's ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffff over 47 charecters with there thumb on the key button. i was thinking of using trim on the wordwrap function but then i get the text all smasched together. so how does one get the database to halt if a user keeps there finger on a key to submit to a database cheers. Link to comment https://forums.phpfreaks.com/topic/42995-text-help-cheers/ Share on other sites More sharing options...
redarrow Posted March 16, 2007 Author Share Posted March 16, 2007 maybe an idear dont no theo <?php if(eregi("^[a-z0-9]$",$word)){ if (strlen($word >42)){ echo "sorry this can not be entred into the database"; } } ?> Link to comment https://forums.phpfreaks.com/topic/42995-text-help-cheers/#findComment-208811 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 strlen is probably the easiest: if (strlen($_POST['userinput']) > 47)) { die("You entered too many characters"); } Damn redarrow beat me, still posting =) Link to comment https://forums.phpfreaks.com/topic/42995-text-help-cheers/#findComment-208814 Share on other sites More sharing options...
obsidian Posted March 16, 2007 Share Posted March 16, 2007 You could use a regexp to see if one word contains more than 47 of the same letter consecutively, but I'm not sure this is exactly what you're after: <?php preg_match_all('|\b(.+?.{47,}.+?)\b|', $string, $matches, PREG_PATTERN_ORDER); if (isset($matches[1]) && count($matches[1]) > 0) { // error encountered echo "<pre>\n"; print_r($matches[1]); echo "</pre>\n"; } ?> Don't have the time to test it right away, but I believe that will match any word that contains a single character repeated 47 or more times. Link to comment https://forums.phpfreaks.com/topic/42995-text-help-cheers/#findComment-208815 Share on other sites More sharing options...
redarrow Posted March 16, 2007 Author Share Posted March 16, 2007 i want a new <br> brake afther every 42 charecters i tried the following but, All dont work in ie why? i am using wordwrap already so that out sorry. have also tried the \n and \n\t and \n\br> also tried foreach and for loop and while but can not get it going. <?php $word="hitheredsfdfsdfsdffdfsffsdfffsdsdffsdffsdfffffffffffffffffff fffdfdfdsfsddffdffsffsdfdsfd"; $x=explode(" ", $word); $y=implode(" ",$x); $y[41]="<br/>"; echo $y; ?> Link to comment https://forums.phpfreaks.com/topic/42995-text-help-cheers/#findComment-208898 Share on other sites More sharing options...
Barand Posted March 16, 2007 Share Posted March 16, 2007 Wordwrap breaks on word boundaries unless you set the 4th argument to true <?php $word="hitheredsfdfsdfsdffdfsffsdfffsdsdffsdffsdffffffffffffffffffffffdfdfdsfsddffdffsffsdfdsfd"; $x = wordwrap($word, 42, '<br>', true); echo $x; ?> -->[pre] hitheredsfdfsdfsdffdfsffsdfffsdsdffsdffsdf fffffffffffffffffffffdfdfdsfsddffdffsffsdf dsfd [/pre] Link to comment https://forums.phpfreaks.com/topic/42995-text-help-cheers/#findComment-208990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.