Wednesday 19 February 2014

Filled Under:
,

wordwrap in php

              word wrap a wraps and break string to a given number of characters.here given different example and well explained with syntax.also a word wrap a one of the php string function.and this function contain four argument within it.

Syntax :

string wordwrap ( string $str [, int $width = 75 [, string $break = "\n" [, bool TRUE/FALSE ]]] )

str      : string.
Width : The number of characters length which the string will be wrapped.
break : The line is broken using optional break statement like "\n".
cut     : if cur is set TRUE than string will be always wrapped before the specified width.if you want to your string
        larger than given width than remove this parameter from string. like this,

     wordwrap('Hello world !', 3, "<br />\n");

Example :


<?php
    $text = "Easyscript Provide Fresh and Easy script To Learn Website Development.";
    $newtext = wordwrap($text, 20, "<br />\n");

    echo $newtext;
?>

Output :

Easyscript Provide F<br />
resh and Easy script<br />
 script To Learn Website De<br />
velopment.


Example :

<?php
    $text = "Easyscript Provide Fresh and Easy script To Learn Website Development.";
    $newtext = wordwrap($text, 20, "\n");

    echo $newtext;
?>

Output :

Easyscript Provide F
resh and Easy script
 script To Learn Website De
velopment.

Wordwrap in css

p {word-wrap:break-word;}




0 comments:

Post a Comment