note 28934 added to function.str-pad
| From: | eistoeter at gmx dot de | Date: | Tue, 28 Jan 2003 14:16:02 +0000 |
| Subject: | note 28934 added to function.str-pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42929@lists.php.net to get a copy of this message | ||
Maybe you know from other languages (like basic), that you can add a string to another string like
this:
$string = $string + $string2;
This won't work in php! You could use STR_PAD to add a string to another string.
$chars_string1 = strlen($string1);
$chars_string2 = strlen($string2);
$chars = $chars_string1 + $chars_string2;
$string1 = str_pad($string1, $chars, $string2, STR_PAD_RIGHT);
BUT!!!!!!! There's a so much easier way to do the same:
$string1 = "blub"; $string2 = "blab";
$string1 = "".$string1." ".$string2."";
print $string1;
This would print out "blub blab"!!
--
http://www.php.net/manual/en/function.str-pad.php
http://master.php.net/manage/user-notes.php?action=edit+28934
http://master.php.net/manage/user-notes.php?action=delete+28934
http://master.php.net/manage/user-notes.php?action=reject+28934