note 72091 added to function.chr
| From: | PaddyandGer at osu1 dot php dot net | Date: | Tue, 02 Jan 2007 13:35:55 +0000 |
| Subject: | note 72091 added to function.chr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121187@lists.php.net to get a copy of this message | ||
This is just a small piece that allows you to echo out a set number of characters from a string. We
were writing option values (html form element) dynamically from an xml file. Some of the strings
were too long and as the select tag has no attributes to control the width or columns it seems a
handy way to solve the problem.
$string = "this is some text";
$length = strlen($string); // gets the length of the string
$newLength = -($length - 5); // makes the length smaller by 5 characters
$string = substr("$string", 0, $newLength); // sets the string to be 5 characters in
length
echo $string;
----
Server IP: 212.108.64.74
Probable Submitter: 136.206.1.17 (proxied: 136.206.229.110)
----
Manual Page -- http://www.php.net/manual/en/function.chr.php
Edit -- https://master.php.net/note/edit/72091
Del: integrated -- https://master.php.net/note/delete/72091/integrated
Del: useless -- https://master.php.net/note/delete/72091/useless
Del: bad code -- https://master.php.net/note/delete/72091/bad+code
Del: spam -- https://master.php.net/note/delete/72091/spam
Del: non-english -- https://master.php.net/note/delete/72091/non-english
Del: in docs -- https://master.php.net/note/delete/72091/in+docs
Del: other reasons-- https://master.php.net/note/delete/72091
Reject -- https://master.php.net/note/reject/72091
Search -- https://master.php.net/manage/user-notes.php