Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


8,101 questions

11,281 answers

573 users

How to swap between two languages (ltr and rtl) in a web page with PHP and HTML

1 Answer

0 votes
if (!empty($_GET['language'])) 
    $_COOKIE['language'] = $_GET['language'];
else 
    $_COOKIE['language'] = 'en';

setcookie('language', $_COOKIE['language']);
 
if ($_COOKIE['language'] == "en") { 
   $textdir = "ltr";
}
else if ($_COOKIE['language'] == "he") {
        $textdir = "rtl";
}
<!doctype html>
<html lang="<?php echo $_COOKIE['language']; ?>" dir="<?php echo $textdir; ?>">
    <head>
         ...
    </head>
    <body>
           <a href="index.php?language=en">English</a>
           <a href="index.php?language=he">Hebrew</a>
    </body>
</html>

 




answered Jun 9 by avibootz
edited Jun 9 by avibootz
...