Answers for "php lpad"

PHP
8

php 0 padding left

<?php
$input = "Alien";
echo str_pad($input, 10);                      // produces "Alien     "
echo str_pad($input, 10, "-=", STR_PAD_LEFT);  // produces "-=-=-Alien"
echo str_pad($input, 10, "_", STR_PAD_BOTH);   // produces "__Alien___"
echo str_pad($input,  6, "___");               // produces "Alien_"
echo str_pad($input,  3, "*");                 // produces "Alien"
?>
Posted by: Guest on May-14-2020
-1

php clear echo

<?php

ob_start();
echo 'a';
print 'b';

// some statement that removes all printed/echoed items
ob_end_clean();

echo 'c';

// the final output is equal to 'c', not 'abc'

?>
Posted by: Guest on July-10-2020
-1

php rtrim

$colors=trim("blue,red,green,",",");//remove last , with rtrim
Posted by: Guest on November-20-2020

Browse Popular Code Answers by Language