Ejemplo n.º 1
0
 /**
  * Test the strrev method.
  */
 public function test_strrev()
 {
     $strings = array("Žluťoučký koníček" => "kečínok ýkčuoťulŽ", 'ŽLUŤOUČKÝ KONÍČEK' => "KEČÍNOK ÝKČUOŤULŽ", '言語設定' => '定設語言', '简体中文' => '文中体简', "Der eine stößt den Speer zum Mann" => "nnaM muz reepS ned tßöts enie reD");
     foreach ($strings as $before => $after) {
         // Make sure we can reverse it both ways and that it comes out the same.
         $this->assertSame($after, core_text::strrev($before));
         $this->assertSame($before, core_text::strrev($after));
         // Reverse it twice to be doubly sure.
         $this->assertSame($after, core_text::strrev(core_text::strrev($after)));
     }
 }
Ejemplo n.º 2
0
 /**
  * Prepare label's text for GD output.
  *
  * @param string    $label string to be prepared.
  * @return string   Reversed input string, if we are in RTL mode and has no numbers.
  *                  Otherwise, returns the string as is.
  */
 private function prepare_label_text($label)
 {
     if (right_to_left() and !preg_match('/[0-9]/i', $label)) {
         return core_text::strrev($label);
     } else {
         return $label;
     }
 }