fix ehraz

This commit is contained in:
2026-07-16 11:36:57 +03:30
parent d5168dadb2
commit 41c2a20fd0
7 changed files with 82 additions and 10 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Support;
class PersianDigits
{
public static function toEnglish(mixed $value): mixed
{
if (is_string($value)) {
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
$latin = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
$value = str_replace(array_merge($persian, $arabic), array_merge($latin, $latin), $value);
return str_replace('٫', '.', $value);
}
if (is_array($value)) {
return array_map([self::class, 'toEnglish'], $value);
}
return $value;
}
}