The easiest solution is to use wordwrap()
, and explode()
on the new line, like so:
$array = explode( "\n", wordwrap( $str, $x));
Where $x
is a number of characters to wrap the string on.
More Related Contents:
- How to split a string by multiple delimiters in PHP?
- PHP: Split string into array, like explode with no delimiter
- Find a match pattern of any digit and space with any character in a string and replace with | in PHP [closed]
- Remove empty array elements
- Remove new lines from string and replace with one empty space
- Array to String PHP?
- PHP: Split string [duplicate]
- Remove multiple whitespaces
- How to mimic Stack Overflow Auto-Link Behavior
- Remove control characters from PHP string
- Convert flat array to a delimited string to be saved in the database
- php implode (101) with quotes
- use strings to access (potentially large) multidimensional arrays
- String contains any items in an array (case insensitive)
- How to cast array elements to strings in PHP?
- Search and replace multiple values with multiple/different values in PHP5?
- Explode string into array with no empty elements?
- Close open HTML tags in a string
- How to search in an array with preg_match?
- Regex & PHP – isolate src attribute from img tag
- Remove accents without using iconv
- PHP get values from SimpleXMLElement array
- How to implode array with key and value without foreach in PHP
- Split array into two arrays by index even or odd
- php split array into smaller even arrays
- How to convert array values to lowercase in PHP?
- Remove all non-numeric characters from a string; [^0-9] doesn’t match as expected
- Convert a String to Variable
- Search and replace multiple values with multiple/different values in PHP?
- Check if string contains word in array [duplicate]