PHP wordwrap() ফাংশন

উদাহরণ

নির্দিষ্ট দৈর্ঘ্যের মধ্যে স্ট্রিংকে সরাসরি লাইন ভাগ করা:

<?php
$str = "দীর্ঘ শব্দের একটি উদাহরণ: Supercalifragulistic";
echo wordwrap($str,15,"<br>\n");
?>

Run Instance

সংজ্ঞা ও ব্যবহার

wordwrap() ফাংশন নির্দিষ্ট দৈর্ঘ্যের মধ্যে স্ট্রিংকে সরাসরি লাইন ভাগ করে নেয়।

Comment:This function may leave whitespace characters at the beginning of the line.

Syntax

wordwrap(string,width,break,cut)
Parameter Description
string Required. Specify the string to be wrapped.
width Optional. Specify the maximum line width. The default is 75.
break Optional. Specify the character (or string) used as a separator. The default is "\n".
cut

Optional. Specify whether to wrap words longer than the specified width:

  • FALSE - Default. No-wrap
  • TRUE - Word-wrap

Technical Details

Return Value: If successful, it returns the wrapped string. If failed, it returns FALSE.
PHP Version: 4.0.2+
Update Log: In PHP 4.0.3, a new cut Parameters.

More Examples

Example 1

Use all parameters:

<?php
$str = "An example of a long word is: Supercalifragulistic";
echo wordwrap($str,15,"<br>\n",TRUE);
?>

Run Instance

Example 2

Word-wrap strings:

<?php
$str = "An example of a long word is: Supercalifragulistic";
echo wordwrap($str,15);
?>

HTML output of the above code (see source code):

<!DOCTYPE html>
<html>
<body>
An example of a
long word is:
Supercalifragulistic
</body>
</html>

Browser output of the above code:

An example of a long word: Supercalifragulistic

Run Instance