loop foreach php [duplicate]

0

Hello, I am studying a code that I found on the internet and I am doubtful in this part here:

 foreach($arrayDados as $chave => $valor):   
      $campos .= $chave . ', ';   
      $valores .= '?, ';   
   endforeach;   

The point between the $ key variable and the comma that were assigned to the $ fields variable is for concatenation, however I did not understand the strong>) between the $ code variable and the "=" sign and the same point appears between the variable $ values and the equality. Without them the code does not work right

    
asked by anonymous 03.05.2018 / 14:11

1 answer

0

It is an assignment operator, it is used to concatenate the existing value with the new value, it is the same as:

 foreach($arrayDados as $chave => $valor):   
  $campos = $campos.$chave . ', ';   
  $valores = $valores.'?, ';   
    
03.05.2018 / 14:17