Reputation: 3829
I wanted to break a string into max 35 character
but with intelligent break. Suppose i have string below:
street name, sector name, city, state, pincode
or
ABC Heights, Golf Road, City Test, City Sector
Now, i want these strings to be break in anyway but it shall be intelligent not to break any wrong line.
Eg. break can be
ABC Heights, Golf Road,<br/>
City Test, City Sector
NOT
ABC Heights, Golf Road,City Te<br/>
st, City Sector
I have tried answers here
but no luck.
Upvotes: 0
Views: 70
Reputation: 1816
Something like?
<?php
$string = "ABC Heights, Golf Road, City Test, City Sector";
echo wordwrap($string, 35, "<br />\n");
?>
Which would result in
ABC Heights, Golf Road, City Test,
City Sector
See http://php.net/manual/en/function.wordwrap.php for more details.
Upvotes: 1