Jump to content

Archived

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

redarrow

edit is this code correct does not work substr cheers.

Recommended Posts

how do i add a brake from the database when echo the letters out.

so if there was a sentence with 200 letters how do i get a brake in there afther 50 letters cheers.

Share this post


Link to post
Share on other sites
[url=http://php.net/wordwrap]wordwrap[/url]() might help you.

Share this post


Link to post
Share on other sites
I had an idear it was wordwrap can you kindly exsplain what the 1 for cheers.

<?

$word=array("12345678901234567890123456789012345678901234567890123324342343");

foreach($word AS $a);

$result=wordwrap($a,50,"<br>",1);

echo $result;

?>

Share this post


Link to post
Share on other sites
[quote]can you kindly exsplain what the 1 for cheers[/quote]
The [url=http://php.net/wordwrap]manual[/url] does a fine job of explaining it. What more can I say?

Share this post


Link to post
Share on other sites
Is there a php statement that i can work out how to have only the amount of charecters i wont cheers.

Share this post


Link to post
Share on other sites
i wont to find a way to specefi how many charecters to show from the database.

i wont to learn the code properly but i wont to use if possable a php statement like the wordwrap easy and stright foward.

Share this post


Link to post
Share on other sites
Um... ive allready pointed you to the wordwrap manual twice. What part don't you understand?

Share this post


Link to post
Share on other sites
I got word wrap working cheers.

this word wrap is for making a brake or new line i also was wanting substr ok but cheers.

ps. if you know of a way to get word wrap to preform like substr show me cheers.

$word=array("11111111112222222222");

foreach($word AS $a);

$result=wordwrap($a,10,"<br>",1);

echo $result;


For example say i wanted to show the first 10 numbers only can word wrap do it? .

Share this post


Link to post
Share on other sites
[quote]For example say i wanted to show the first 10 numbers only can word wrap do it?[/quote]
No... use [url=http://php.net/substr]substr[/url]().

Share this post


Link to post
Share on other sites
can someone show me kindly what i done wrong please cheers.

<?

$word=array("11111111112222222222");


for($i=0; $i<count($word); $i++){

$word=$word[$i];
}

$text = "$word";

echo ShortenString($text);

function ShortenString($text)

{

// Number of characters you want to display

$num_chars = 19;

$text = $text." ";

$text = substr($text,0,$num_chars);

$text = substr($text,0,strrpos($text,' '));

return $text;

}

?>

Share this post


Link to post
Share on other sites

×

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.