I have a problem with a function I have written in php. As you can see the function uses itself to return an array of the values.
public function getRepeat($day = "array")
{
if ($day == 'array')
{//Return an array with the repeated days as values
foreach (array(1,2,3,4,5,6,0) as $value)
{
if ($this->getRepeat($value))
{
$returnArray[] = $value;
}
}
return $returnArray;
}
else if (in_array($day, array(1,2,3,4,5,6,0) ))
{
if ($day == 1)
return $this->repeat1;
if ($day == 2)
return $this->repeat2;
if ($day == 3)
return $this->repeat3;
if ($day == 4)
return $this->repeat4;
if ($day == 5)
return $this->repeat5;
if ($day == 6)
return $this->repeat6;
if ($day == 0)
return $this->repeat0;
}
}
As soon as it calls itself to get each of the variables it turns into an endless loop.
What causes this?