cvs: phpdoc /en/reference/strings/functions substr.xml

From: Date: Tue, 18 Jan 2005 15:45:46 +0000
Subject: cvs: phpdoc /en/reference/strings/functions substr.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969366030@lists.php.net to get a copy of this message
aidan Tue Jan 18 10:45:46 2005 EDT Modified files: /phpdoc/en/reference/strings/functions substr.xml Log: Added examples for accesing the last char of a string (I always forget!) http://cvs.php.net/diff.php/phpdoc/en/reference/strings/functions/substr.xml?r1=1.9&r2=1.10&ty=u Index: phpdoc/en/reference/strings/functions/substr.xml diff -u phpdoc/en/reference/strings/functions/substr.xml:1.9 phpdoc/en/reference/strings/functions/substr.xml:1.10 --- phpdoc/en/reference/strings/functions/substr.xml:1.9 Sat Jul 3 08:13:06 2004 +++ phpdoc/en/reference/strings/functions/substr.xml Tue Jan 18 10:45:45 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 --> <refentry id="function.substr"> <refnamediv> @@ -33,15 +33,19 @@ <programlisting role="php"> <![CDATA[ <?php -$rest = substr("abcdef", 1); // returns "bcdef" -$rest = substr("abcdef", 1, 3); // returns "bcd" -$rest = substr("abcdef", 0, 4); // returns "abcd" -$rest = substr("abcdef", 0, 8); // returns "abcdef" +echo substr('abcdef', 1); // bcdef +echo substr('abcdef', 1, 3); // bcd +echo substr('abcdef', 0, 4); // abcd +echo substr('abcdef', 0, 8); // abcdef +echo substr('abcdef', -1, 1) // f -// Accessing via curly braces is another option +// Accessing single characters in a string +// can also be achived using "curly braces" $string = 'abcdef'; -echo $string{0}; // returns a -echo $string{3}; // returns d +echo $string{0}; // a +echo $string{3}; // d +echo $string{strlen($string)-1} // f + ?> ]]> </programlisting>

« previous php.doc (#969366030) next »