0
So my cookies look like so


    Name: lang
    Content: et
   and
    Name: lang
    Content: en
   and
    Name: lang
    Content: fi



every language select deletes old and replaces with new one
I need to get my script working with every cookie content different text




    $array = array();

    $array[] = 'blabla 1';
    $array[] = 'blabla 2';
    $array[] = 'blabla 3';
    $array[] = 'blabla 4';

    $random = rand(0, count($array));

    echo $array[$random];



and if there is no cookies, then it will show content:et arrays
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Biiim
0

Your query is bit not clear.
Do you want to save all 3 language names into one array.
If user select any language then set selected language in cookie.
when page is loaded check cookie value and based on that fetch content..
Is that so??

1
<?php
$languages = array('en'=>'blabla 0','fi'=>'blabla 1','et'=>'blabla 2');
$langPicked = false;
foreach($languages as $k=>$v){
    if($_COOKIE['content'] == $k){
        $lang = $k;
        $langPicked = true;
    }
}
if($langPicked === false){
    $lang = 'en';
}

//$lang == 'en' || 'fi' || 'et'
//$languages[$lang] == 'blabla 0' || 'blabla 1' || 'blabla 2'
?>

Edited by Biiim: typo

Votes + Comments
exact logic
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.