I have two Inputs ( curso[]
and formacao[]
) html
and when looping with foreach
and starts to duplicate the items that are within the second foreach
This is my class
class Pessoa {
private $Formacao;
private $Cursos;
function __construct($Formacao,$Cursos)
{
$this->Formacao = (array) $Formacao;
$this->Cursos = (array) $Cursos;
}
public function setFormacao($Formacao){
$this->Formacao = $Formacao;
}
public function getFormacao(){
return $this->Formacao;
}
public function setCursos($Cursos){
$this->Cursos = $Cursos;
}
public function getCursos(){
return $this->Cursos;
}
public function getBody(){
foreach ($this->getFormacao() as $formacao) {
$body = "<ul><li>{$formacao}";
foreach ($this->getCursos as $cursos) {
$body.= "{$cursos}</li></ul>";
}
}
return $body;
}