/** * @dataProvider providerUtf8GetLastChar */ public function testUtf8GetLastChar($str, $rchars, $runicode) { $chars = $unicode = array(); while (($char = utf8_get_last_char($str, $i, $cp)) !== false) { $chars[] = $char; $unicode[] = $cp; } $this->assertEquals($chars, $rchars); $this->assertEquals($unicode, $runicode); }
/** * Returns a string with the characters in reverse order. * * @param string $str The UTF-8 encoded string * @return string with the characters in reverse order */ function utf8_reverse($str) { $rv = ''; while (($char = utf8_get_last_char($str, $i)) !== false) { $rv .= $char; } return $rv; }