PHP 访问单个字符 本文最后更新于:2024年3月18日 凌晨 PHP 访问单个字符 函数strlen()返回字符串中的字符数,即字符长度: 12$string = 'Hello, world';$length = strlen($string); //$length为12 可以在字符串中使用字符串偏移量语法来定位单个字符: 12345678910$string = 'Hello';for($i = 0;$i < strlen($string);$i++){ print("The %dth character is %s\n",$i,$string{$i});}The 0th character is HThe 1th character is eThe 2th character is lThe 3th character is lThe 4th character is o Software Language PHP 字符串 本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处! PHP 创建对象 上一篇 PHP 编码与转义 下一篇