字符串倒序输出-多种方法
2015-07-27 18:54
162 查看
//+++字符串倒序+++// $str='123456789abcdefg'; //$str='我爱你';//utf8下1个中文3个字节,gbk下2个字节,用str_split的时候注意 //1 echo strrev($str); //2 $lenght=strlen($str); $toStr=''; for($i=$lenght-1;$i>=0;$i--){ $toStr.=$str[$i]; } echo $toStr; //3 $strArr=str_split($str,1); $strArr=array_reverse($strArr); print_r($strArr); echo implode($strArr);
相关文章推荐
- 整数变字符串 字符串变整数
- 赛前必须看的细节
- POJ题目细究
- hdu 2492 树状数组 Ping pong
- 给eclipse配置sublime主题的背景
- shell常用的 if语句【-x file】
- Linux系统下安装rz/sz命令及使用说明
- POJ 1068 Parencodings(模拟)
- 使用LabVIEWPC的制备
- 折半代码处理。短信发送。
- Alternating Least Squares(ASL) for Implicit Feedback Datasets的数学推导以及用Python实现
- 课堂笔记04
- Linux的磁盘管理
- cocos2dx飞机大战开发记录(1)
- 计算干支纪年具体年月日的方法
- getResourceAsStream(“”)路径问题
- ubuntu python 安装
- LeetCode 238: Product of Array Except Self
- shell
- 基于ZXing的二维码,你可以这样改造它