Store all the data you want to return in a string, and later return the string:
public function something() {
$result = ""; // Create empty string
foreach($array as $val) {
$result .= "something"; // Add something to the string in the loop
}
return $result; // Return the full string
}
An alternative (since you already have an array) would be mapping the array to your string values and returing the imploded the array like so:
public function something() {
return implode('', array_map(function($val) {
return "something";
}, $array));
}
2
solved Using return in foreach not echo with medoo