irvatoDev
5/1/2015 - 8:27 PM

Change en to fa all numbersinto all pages when page compile with blade

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);
  }