string.php
Tags
Table of Contents
Functions
- toString() : string|callable
- Converts value to string.
- startsWith() : bool|callable
- Returns true if given `$item` starts with `$expected` value.
- endsWith() : bool|callable
- Returns true if given `$item` ends with `$expected` value.
- matches() : bool|callable
- Test regular expression against a sting. Returns all matching elements or empty array if there aren't any.
Functions
toString()
Converts value to string.
toString(mixed ...$v) : string|callable
toString(1) // it will return '1'
toString(true) // it will return '1'
toString(null) // it will return ''
Parameters
- $v : mixed
Return values
string|callable —If all arguments are given result is returned. Passing just some or none will result in currying function return.
startsWith()
Returns true if given `$item` starts with `$expected` value.
startsWith(mixed ...$v) : bool|callable
startsWith('Lorem ipsum', 'Lorem ipsum 123') // it will return true
startsWith(' Lorem ipsum', 'Lorem ipsum 123') // it will return false
startsWith('lorem ipsum', 'Lorem ipsum 123') // it will return false
Parameters
- $v : mixed
Return values
bool|callable —If all arguments are given result is returned. Passing just some or none will result in currying function return.
endsWith()
Returns true if given `$item` ends with `$expected` value.
endsWith(mixed ...$v) : bool|callable
endsWith('123', 'Lorem ipsum 123') // it will return true
endsWith('123 ', 'Lorem ipsum 123') // it will return false
endsWith('M 123', 'Lorem ipsum 123') // it will return false
Parameters
- $v : mixed
Return values
bool|callable —If all arguments are given result is returned. Passing just some or none will result in currying function return.
matches()
Test regular expression against a sting. Returns all matching elements or empty array if there aren't any.
matches(string ...$v) : bool|callable
matches('/([a-z]a)/', 'bananas') // it will return ['ba', 'na', 'na']
matches('/a/', 'b') // it will return []
Parameters
- $v : string
Return values
bool|callable —If all arguments are given result is returned. Passing just some or none will result in currying function return.