From bea96b6ea9650d5c660b9bfb5bd6c52266f4b8bc Mon Sep 17 00:00:00 2001 From: ali Date: Tue, 25 Nov 2003 22:07:25 +0000 Subject: [PATCH] clarification: curly braces can be used to modify strings, too git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@144915 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/types.xml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/language/types.xml b/language/types.xml index 2b6a2394eb..95b7fdbc06 100644 --- a/language/types.xml +++ b/language/types.xml @@ -1,5 +1,5 @@ - + Types @@ -1029,9 +1029,9 @@ echo "I'd like to have another {${ strrev('reeb') }}, hips"; - String access by character + String access and modification by character - Characters within strings may be accessed by specifying the + Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string in curly braces. @@ -1058,6 +1058,11 @@ $third = $str{2}; // Get the last character of a string. $str = 'This is still a test.'; $last = $str{strlen($str)-1}; + +// Modify the last character of a string +$str = 'Look at the sea'; +$str{strlen($str)-1} = 'e'; + ?> ]]>