Accessing string offsets in PHP

$str = "M";
$str{2} = "n";
$str{1} = "a";
$str = $str . "i";
print $str;

The above code will output “Mani”. Individual characters in a string can be accessed using the $str{offset} notation. You can use it to both read and write string offsets.

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.