Skip to content

Instantly share code, notes, and snippets.

@abrahamfast
Created May 1, 2015 20:27
Show Gist options
  • Save abrahamfast/67ce029e4f9c4b214c3e to your computer and use it in GitHub Desktop.
Save abrahamfast/67ce029e4f9c4b214c3e to your computer and use it in GitHub Desktop.
Change en to fa all numbersinto all pages when page compile with blade
<?php
Blade::extend(function($view, $compiler)
{
$pat = $compiler->createMatcher('traverse_farsi');
return preg_replace($pat, '$1<?php echo traverse_farsi($2) ;?>', $view);
});
function traverse_farsi ($str){
$farsi_chars = ['٠','١','٢','٣','٤','٥','٦','٧','٨','٩'];
$latin_chars = ['0','1','2','3','4','5','6','7','8','9'];
return str_replace($latin_chars,$farsi_chars,$str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment