CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.0 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.0
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Auth
    • Core
    • Error
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • ClassRegistry
  • Debugger
  • File
  • Folder
  • Inflector
  • ObjectCollection
  • Sanitize
  • Security
  • Set
  • String
  • Validation
  • Xml

Class String

String handling methods.

Package: Cake\Utility
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Utility/String.php

Method Summary

  • cleanInsert() public static

    Cleans up a String::insert() formatted string with given $options depending on the 'clean' key in $options. The default method used is text but html is also available. The goal of this function is to replace all whitespace and unneeded markup around placeholders that did not get replaced by String::insert().

  • insert() public static

    Replaces variable placeholders inside a $str with any given $data. Each key in the $data array corresponds to a variable placeholder name in $str. Example: String::insert(':name is :age years old.', array('name' => 'Bob', '65')); Returns: Bob is 65 years old.

  • tokenize() public static

    Tokenizes a string using $separator, ignoring any instance of $separator that appears between $leftBound and $rightBound

  • uuid() public static
    Generate a random UUID
  • wrap() public static
    Wraps text to a specific width, can optionally wrap at word breaks.

Method Detail

cleanInsert() public static ¶

cleanInsert( string $str , string $options )

Cleans up a String::insert() formatted string with given $options depending on the 'clean' key in $options. The default method used is text but html is also available. The goal of this function is to replace all whitespace and unneeded markup around placeholders that did not get replaced by String::insert().

Parameters
string $str
string $options
Returns
string
See
String::insert()

insert() public static ¶

insert( string $str , string $data , string $options = array() )

Replaces variable placeholders inside a $str with any given $data. Each key in the $data array corresponds to a variable placeholder name in $str. Example: String::insert(':name is :age years old.', array('name' => 'Bob', '65')); Returns: Bob is 65 years old.

Available $options are:

  • before: The character or string in front of the name of the variable placeholder (Defaults to :)
  • after: The character or string after the name of the variable placeholder (Defaults to null)
  • escape: The character or string used to escape the before character / string (Defaults to \)
  • format: A regex to use for matching variable placeholders. Default is: /(?<!\\)\:%s/ (Overwrites before, after, breaks escape / clean)
  • clean: A boolean or array with instructions for String::cleanInsert
Parameters
string $str
A string containing variable placeholders
string $data

A key => val array where each key stands for a placeholder variable name to be replaced with val

string $options optional array()
An array of options, see description above
Returns
string

tokenize() public static ¶

tokenize( string $data , string $separator = ',' , string $leftBound = '(' , string $rightBound = ')' )

Tokenizes a string using $separator, ignoring any instance of $separator that appears between $leftBound and $rightBound

Parameters
string $data
The data to tokenize
string $separator optional ','
The token to split the data on.
string $leftBound optional '('
The left boundary to ignore separators in.
string $rightBound optional ')'
The right boundary to ignore separators in.
Returns
array
Array of tokens in $data.

uuid() public static ¶

uuid( )

Generate a random UUID

Returns
RFC
4122 UUID
See
http://www.ietf.org/rfc/rfc4122.txt

wrap() public static ¶

wrap( string $text , mixed $options = array() )

Wraps text to a specific width, can optionally wrap at word breaks.

Options

  • width The width to wrap to. Defaults to 72
  • wordWrap Only wrap on words breaks (spaces) Defaults to true.
  • indent String to indent with. Defaults to null.
  • indentAt 0 based index to start indenting at. Defaults to 0.
Parameters
string $text
Text the text to format.
mixed $options optional array()
Array of options to use, or an integer to wrap the text to.
Returns
string
Formatted text.
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs