note 38259 added to function.sprintf

From: Date: Sun, 14 Dec 2003 03:46:56 +0000
Subject: note 38259 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-61924@lists.php.net to get a copy of this message
function pad_text($str,$howmuch,$with,$side=""){ if($side=="LEFT"||$side==""){ for($i=strlen($str);$i<$howmuch;$i++){ $str = $with.$str; } return $str; } if($side=="RIGHT"){ for($i=strlen($str);$i<$howmuch;$i++){ $str = $str.$with; } return $str; } } I thing there should be a padding function by itself. here is a function i wrote to pad binary numbers with the decbin function. pad_text(string string,integer pad length,string pad character,[string side to pad]); The fourth, optional, variable is either set to LEFT or RIGHT. If nothing is set then it is assumed to pad the LEFT side. ---- Manual Page -- http://www.php.net/manual/en/function.sprintf.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38259 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38259&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38259&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61924) next »