WireTextTools::collapse() method

Collapse string to plain text that all exists on a single long line without destroying words/punctuation.

Usage

// basic usage
$mixed = $wireTextTools->collapse(string $str);

// usage with all arguments
$mixed = $wireTextTools->collapse(string $str, array $options = []);

Arguments

NameType(s)Description
strstring

String to collapse

options (optional)array
  • stripTags (bool): Strip markup tags? (default=true)
    • keepTags (array): Array of tag names to keep, if stripTags==true. (default=[])
    • collapseLinesWith (string): String to collapse newlines with. (default=' ')
    • linksToUrls (bool): Convert links to "(url)" rather than removing entirely? (default=false) Since 3.0.132
    • endBlocksWith (string): Character or string to insert to identify paragraph/header separation (default='')
    • convertEntities (bool): Convert entity-encoded characters to text? (default=true)

Return value

mixed string


WireTextTools methods and properties

API reference based on ProcessWire core version 3.0.148

Twitter updates

  • This week we’ve got a few new and interesting core updates in progress, though none quite ready to release just yet. So rather than releasing version 3.0.154 today, I thought we'd instead take a brief look at what’s coming over the next few weeks… More
    3 April 2020
  • ProcessWire 3.0.153 (dev) focuses on comments field updates, significant refactoring/improvements to ProcessWire’s core Template class and PagesLoader class (which is used by the pages API variable), and we introduce a useful new pages API method— More
    20 March 2020
  • ProcessWire 3.0.152 core updates— This week we have some major improvements to our core date/time Inputfield, as well as a new ability to specify your own custom classes for Page objects— More
    6 March 2020

Latest news

  • ProcessWire Weekly #308
    In the 308th issue of ProcessWire Weekly we're going to take a look at some upcoming core and pro module updates, check out two all-new third party modules, and more. Read on!
    Weekly.pw / 4 April 2020
  • ProcessWire updates and additions in progress
    This week we’ve got a few new and interesting core updates in progress, though none quite ready to release just yet. So rather than releasing version 3.0.154 today, I thought we'd instead take a brief look at what’s coming over the next few weeks. This post covers all the details.
    Blog / 3 April 2020
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK