Reputation: 6436
Supposing I have an array Tomat, Ost
How can I accomplish so it is like this: Tomat, ost
?
$ingredient_a = Array('Tomat', 'Ost');
echo implode(', ', $ingredient_a);
Upvotes: 0
Views: 389
Reputation: 31
$ingredient_a = array('Tomat', 'Ost');
$new = array();
foreach($ingredient_a as $key => $value) {
$key == 0 ? $new[] = $value : $new[] = strtolower($value);
}
echo implode(', ', $new);
Upvotes: 0
Reputation: 254
Use ucfirst
and array_map
with strtolower
echo ucfirst(implode(', ', array_map('strtolower',$ingredient_a)));
Upvotes: 5