Jump to content

text help cheers.


redarrow

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.