save the cookies to the array and then print

0

I'm trying to do the following: Each time he clicks the button, the counter counts + 1, and this amount will be used in the foreach for it to save in cookies. see my code:

$contar = 0;

if(isset($_POST['submit'])){
  $contar = $contar + 1;
}

if (isset($_POST['ideia'])) {
  


$cookie_value= $_POST['ideia'];
foreach ($contar as $id) {

 setcookie('text['.$id.']',$cookie_value,time()+36000);
}

}
    
asked by anonymous 23.07.2018 / 23:10

1 answer

0

According to the PHP documentation link

foreach (array_expression as $value)
    statement
foreach (array_expression as $key => $value)
    statement

Error

$ count is not an array

    
23.07.2018 / 23:20