Morilog\Jalali\jDateTime::convertNumbers PHP Method

convertNumbers() public static method

Convert Latin numbers to persian numbers
public static convertNumbers ( string $string ) : string
$string string
return string
    public static function convertNumbers($string)
    {
        $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹");
        $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
        return str_replace($english_array, $farsi_array, $string);
    }

Usage Example

Ejemplo n.º 1
0
 public function test_format_with_convert_to_persian()
 {
     $object = new jDate();
     $jDate = $object->forge('2015-06-13')->format('Y-m-d');
     $this->assertTrue('۱۳۹۴-۰۳-۲۳' === \Morilog\Jalali\jDateTime::convertNumbers($jDate));
 }
All Usage Examples Of Morilog\Jalali\jDateTime::convertNumbers