title: How to echo a variable in an array?
body: <p>Is it possible to echo a variable in an array? Imm trying to create CSS via PHP:</p>
  
  <pre><code>class headerStyle{
      // now  creating our CONSTRUCTOR function
      function __construct($args=array()) {
          $this-&gt;fields = array('background','color','fontSize','backgroundUrl','imagePosition','Width','Height','backgroundSize','margin','padding','backgroundRepeat');
          foreach ($this-&gt;fields as $field) {
              $this-&gt;{"$field"} = $args["$field"];
          }
      }
  }
  
  
  $value = $_POST['mainHeaderBg'];
  
  setcookie("TestCookie", $value);
  setcookie("TestCookie", $value, time()+3600); 
  $var=($_COOKIE["TestCookie"]);
  $style = new headerStyle(
         array(
           'background'=&gt;echo $var,
           'color'=&gt;"#F5F3F4",
           'fontSize'=&gt;"24px",
           //backgroundUrl=&gt;"_images/bodyBg1.jpg",
           'backgroundSize'=&gt;"50% 50%",
           'padding'=&gt;"10px 0px 0px 0px",
           'margin'=&gt;"0px 0px 0px 0px",
           'width'=&gt;"100%",
           'height'=&gt;"60px",
           'imagePosition'=&gt;"top-left",
         )
  );
  </code></pre>
  
  <p>I need to pass a dynamic variable so that it can display in index. I'm unable to echo a variable in an array.</p>