实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串。

示例 1:

输入: "Hello"
输出: "hello"
示例 2:

输入: "here"
输出: "here"
示例 3:

输入: "LOVELY"
输出: "lovely"

来源:力扣(LeetCode)

代码献上

class Solution {
    /**
     * @param String $str
     * @return String
     */
    function toLowerCase($str) {
        $strlen = strlen($str);
        $arr = str_split($str,1);
        $newstr = '';
        for($i=0;$i<$strlen;$i++){
            
            $ord = ord($arr[$i]);
            if($ord < 97 && $ord > 64){
                $newstr.= chr($ord+32);
            }else{
                $newstr.= $arr[$i];
            }
        }
        return $newstr;
    }
}

最新文章

  1. jpg Test
  2. How to manage the certificates in the PC
  3. UISearchBar改变搜索框的高度
  4. maven install 报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project*****
  5. python堡垒机
  6. 转载 C#使用Salt + Hash来为密码加密
  7. static wechat red package tool
  8. svn“Previous operation has not finished; run &#39;cleanup&#39; if it was interrupted
  9. Class.getResourceAsStream()与ClassLoader.getResourceAsStream()的区别
  10. JS 判断是否为IP格式
  11. 经典面试题:一张表区别DOM解析和SAX解析XML
  12. 你真的了解webview么?
  13. 即时通讯(IV)
  14. git无法识别新增的文件
  15. Elasticsearch5.5.1插件开发指南
  16. npm 安装 cannot find module
  17. HDU 3226 背包
  18. FreeRTOS 低功耗之待机模式
  19. mycat引起的insert后马上select不到数据的故障分析
  20. [分享] 关于App Store下载到一半发生错误的问题 [复制链接]

热门文章

  1. Git 学习第三天(二)
  2. jenkins+jacoco配置代码覆盖率
  3. UI自动化ADB出现devices offline的解决方法
  4. 8-MySQL-Ubuntu-数据表中数据的增加(一)
  5. RedHat版本Linux安装chrome-stable配合chromeDriver进行自动化测试环境准备
  6. Linux --赋予普通用户root 权限
  7. python_django_urls基础配置
  8. VS 解决方案
  9. curl 命令帮助及使用
  10. poi之Excel(在线生成)下载