http://www.php.net/manual/zh/language.types.string.php#language.types.string.substr访问和修改字符串中的字符字符串中的字符可以通过在字符串之后用花括号指定所要字符从零开始的偏移量来访问和修改。 Note: 为了向下兼容,仍然可以用方括号。不过此语法自 PHP 4 起已过时。 Example#3 一些字符串例子 <?php // Get the first character of a string $str = 'This is a test.'; $first = $str{0}; // Get the third character of a string $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';?> http://www.php.net/manual/en/language.types.string.php#language.types.string.substr Note: Accessing variables of other types using [] or {} silently returns NULL.
<?php
// Get the first character of a string
$str = 'This is a test.';
$first = $str{0};
// Get the third character of a string
$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';?>
http://www.php.net/manual/en/language.types.string.php#language.types.string.substr
Note: Accessing variables of other types using [] or {} silently returns NULL.
第一个为1,
第二为 null
$a=(string)$a;
var_dump($a[1]);
那以后根本就不用将字符串进行拆分放入数组了,因为PHP自动已经这样做了。
<?$a='日本';echo $a[0]?>