str::substr PHP Method

substr() static public method

An UTF-8 safe version of substr()
static public substr ( string $str, integer $start, integer $end = null ) : string
$str string
$start integer
$end integer
return string
    static function substr($str, $start, $end = null)
    {
        return mb_substr($str, $start, $end == null ? mb_strlen($str, 'UTF-8') : $end, 'UTF-8');
    }

Usage Example

Ejemplo n.º 1
0
 public function testSubstr()
 {
     $this->assertEquals('Super', str::substr($this->sample, 0, 5));
     $this->assertEquals(' Äwes', str::substr($this->sample, 5, 5));
     $this->assertEquals(' Äwesøme String', str::substr($this->sample, 5));
     $this->assertEquals('tring', str::substr($this->sample, -5));
 }
All Usage Examples Of str::substr