Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. function TranslatedTitle($Title) {
  2. ConnectWithMySQLDatabase();
  3.  
  4.     static $English = [];
  5.  
  6.     if (!count($English)) {
  7.         $v = mysql_query("SELECT English, Bulgarian FROM `ProductTranslations` WHERE `Type`=0"); # ORDER by id ASC
  8.         while($vrowis = mysql_fetch_array($v)){
  9.             $English[] = $vrowis['English'];
  10.             $Bulgarian[] = $vrowis['Bulgarian'];
  11.         }
  12.     }
  13.  
  14.     foreach($English as $word){
  15.        $pos = strpos($Title, $word);
  16.  
  17.        if ($pos !== false) {
  18.           //english word found
  19.           $Title = "$word " . str_replace($English, '', $Title);
  20.           break;
  21.        }
  22.     }
  23.     $TranslatedTitle = str_replace($English, $Bulgarian, $Title);
  24.    
  25.  
  26. return $TranslatedTitle;
  27. }
  28.  
  29. function TranslatedSize($Title) {
  30. ConnectWithMySQLDatabase();
  31.  
  32.     static $English = [];
  33.  
  34.     if (!count($English)) {
  35.         $v = mysql_query("SELECT English, Bulgarian FROM `ProductTranslations` WHERE `Type`=1"); # ORDER by id ASC
  36.         while($vrowis = mysql_fetch_array($v)){
  37.             $English[] = $vrowis['English'];
  38.             $Bulgarian[] = $vrowis['Bulgarian'];
  39.         }
  40.     }
  41.  
  42.     foreach($English as $word){
  43.        $pos = strpos($Title, $word);
  44.  
  45.        if ($pos !== false) {
  46.           //english word found
  47.           $Title = "$word " . str_replace($English, '', $Title);
  48.           break;
  49.        }
  50.     }
  51.     $TranslatedTitle = str_replace($English, $Bulgarian, $Title);
  52.    
  53.  
  54. return $TranslatedTitle;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement