<?php $str = array("one", "two", "three", "four", "five", "six"); ///with str_pad foreach ($str as $value) { if (strlen($value) <= 5) { $pad_str = str_pad($value, 6, " ", STR_PAD_RIGHT); $result = $pad_str.'bar'; echo $result.PHP_EOL; } }
You have javascript disabled. You will not be able to edit any code.