$sanitizer->snakeCase() method

Convert string to be all snake_case (lowercase and underscores)

For example, "Hello World" or "hello-world" becomes "hello_world".

Usage

// basic usage
$string = $sanitizer->snakeCase(string $value);

// usage with all arguments
$string = $sanitizer->snakeCase(string $value, array $options = []);

Arguments

NameType(s)Description
valuestring
options (optional)array
  • allow (string): Characters to allow or range of characters to allow, for placement in regex (default='a-z0-9').
    • hyphen (string): Character to use as the hyphen (default='-')

Return value

string


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.161

Twitter updates

  • ProcessWire 3.0.162 continues improvements to selector operators, fixes various minor issues, adds new API convenience methods, improves documentation, optimizes and refactors various portions of code and DB queries, and more— More
    10 July 2020
  • New dedicated page in our online documentation for Selector Operators: More
    10 July 2020
  • New ProcessWire query expansion search operators can now add automatic word inflections and lemmatisation, enabling you to build even smarter search engines with ProcessWire. More
    3 July 2020

Latest news

  • ProcessWire Weekly #321
    In the 321st issue of ProcessWire Weekly we're going to check out the latest core updates, introduce two new third party modules, and check out a brand new site of the week. Read on!
    Weekly.pw / 4 July 2020
  • Powerful new text-searching abilities in 3.0.160
    In ProcessWire 3.0.160 we’ve got some major upgrades and additions to our text-search abilities. This brings a whole new level of power to $pages->find() and similar API calls, especially when it comes to search engine type queries.
    Blog / 19 June 2020
  • Subscribe to weekly ProcessWire news

“I am currently managing a ProcessWire site with 2 million+ pages. It’s admirably fast, and much, much faster than any other CMS we tested.” —Nickie, Web developer