public static substr ( string $string, integer $start, integer $length = null, array $options = [] ) : string | ||
$string | string | The string to extract the substring from. |
$start | integer | Position of first character in string (offset). |
$length | integer | Maximum numbers of characters to use from string. |
$options | array | Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default. |
return | string | The substring extracted from given string. |
public static function substr($string, $start, $length = null, array $options = array())
{
$defaults = array('name' => 'default');
$options += $defaults;
return static::adapter($options['name'])->substr($string, $start, $length);
}
public function testSubstr() { Multibyte::substr('abcab', 1); $result = $this->adapter->testSubstrArgs; $expected = array('abcab', 1, null); $this->assertEqual($expected, $result); Multibyte::substr('abcab', 1, 2); $result = $this->adapter->testSubstrArgs; $expected = array('abcab', 1, 2); $this->assertEqual($expected, $result); }