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

From: Date: Mon, 08 Jul 2002 20:49:45 +0000
Subject: cvs: phpdoc /en/reference/strings/functions substr.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969347154@lists.php.net to get a copy of this message
philip Mon Jul 8 16:49:45 2002 EDT Modified files: /phpdoc/en/reference/strings/functions substr.xml Log: + Accessing as $string{3} works too. + Added <?php ?> to all examples. Index: phpdoc/en/reference/strings/functions/substr.xml diff -u phpdoc/en/reference/strings/functions/substr.xml:1.2 phpdoc/en/reference/strings/functions/substr.xml:1.3 --- phpdoc/en/reference/strings/functions/substr.xml:1.2 Wed Apr 17 02:44:24 2002 +++ phpdoc/en/reference/strings/functions/substr.xml Mon Jul 8 16:49:45 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 --> <refentry id="function.substr"> <refnamediv> @@ -32,10 +32,17 @@ <title>Basic <function>substr</function> usage</title> <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" + +// Accessing via curly braces is another option +$string = 'abcdef'; +echo $string{0}; // returns a +echo $string{3}; // returns d +?> ]]> </programlisting> </example> @@ -47,9 +54,11 @@ <title>Using a negative <parameter>start</parameter></title> <programlisting role="php"> <![CDATA[ +<?php $rest = substr("abcdef", -1); // returns "f" $rest = substr("abcdef", -2); // returns "ef" $rest = substr("abcdef", -3, 1); // returns "d" +?> ]]> </programlisting> </example> @@ -73,10 +82,12 @@ <title>Using a negative <parameter>length</parameter></title> <programlisting role="php"> <![CDATA[ +<?php $rest = substr("abcdef", 0, -1); // returns "abcde" $rest = substr("abcdef", 2, -1); // returns "cde" $rest = substr("abcdef", 4, -4); // returns "" $rest = substr("abcdef", -3, -1); // returns "de" +?> ]]> </programlisting> </example>

« previous php.doc (#969347154) next »