Hi,
I have tried numerous times to refactor the code below, but it sucks... and the version here is the best I could came up with.
Could you please help me refine it and provide advice?
Asd you can see, it's impossible to say if data will be an array, or a string I can add to my list of cars string.PHP Code:public function getCars()
{
$this->listOfCars= '';
$this->buildListOfCars($this->allTheCars);//turns array into string
return $this->listOfCars;//a string
}
protected function buildListOfCars($allTheCars)
{
foreach($allTheCars as $cars){
if(is_array($cars)){
$this->buildListOfCars($cars);
}
$this->listOfCars.= $cars;
}
}
Regards,
-jj.![]()





Bookmarks