Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
$massive = [1, 2, 3, 4, 5]; foreach($massive as $items){ echo $items. ', '; }
$massive = [1, 2, 3, 4, 5]; $items = join(', ', $massive); //или $items = implode(', ', $massive);
$massive = [1, 2, 3, 4, 5]; $isFirst = true; foreach($massive as $item){ if ($isFirst) { echo $item; $isFirst = false; } else { echo ', '.$item; } }
$massive = [1, 2, 3, 4, 5]; $storage =[]; foreach($massive as $items){ $storage[] = $items.',' ; } rtrim($storage, ','); echo implode('', $storage);
echo rtrim(implode('', $storage), ',');
$massive = [1, 2, 3, 4, 5]; foreach($massive as $items){ $items = $items.',' ; } echo rtrim(implode('', $massive), ',');
$array = [1, 2, 3, 4, 5]; $result = ''; foreach($array as $items){ $result .= $items . ','; } echo rtrim($result, ',');
$massive = [1, 2, 3, 4, 5]; foreach($massive as $key => $items){ $massive[$key] = $items. ','; } echo rtrim(implode('', $massive), ',');