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

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??

<?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'
?>
commented: exact logic +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.