Jump to content

putting variables inside predefined variables. Possible?


jtorral

Recommended Posts

i have javascript that sets a cookie when I click on a link.

I then call the function below to check the value of the cookie.

 

I am trying to use variable $div because I have 20 cookies withe the name xxx_div1 through xxx_div20 therefor I try to create the cookie name in the call so ai can minimize code.

 

If i take the function below and replace $divcn with the actual cookie name it works as expected. If I use the variable, it always goes to the else.

 

function checkdivsettings($div) {

  $divcn = "xxx_" . $div;

  if(isset($_COOKIE[$divcn])) {

      $div = $_COOKIE[$divcn];

  } else {

      $div = "block";

  }

  return $div;

}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.