<?php
    $rtl_langs = array("ar", "fa", "he", "ur", "yi"); // There are a couple or so more. Put the codes of your RTL languages here
    if (in_array ($language, $rtl_langs)) { // Check if the language of the current page is RTL.
      /* Load RTL styles instead of default ones: */
      foreach($css as $media => $types){
        foreach($types as $type => $files){
          foreach($files as $file => $preprocess){
            $element = $file;
            $rtl_style = str_replace(".css","-rtl.css",$file);
            if(file_exists($rtl_style)){
              unset($css[$media][$type][$file]);
              $css[$media][$type][$rtl_style] = $preprocess;
            }
          }
        }
      }
      print drupal_get_css($css);
  	} else {
      print $styles;
  	}
  ?>
