search
Homephp教程PHP源码获取例如aAAAxAAAa里的x规则的PHP方法

至于这个问题,我刚刚小小修改了一下我的程序,现在答案已经出来,请哪位PHP大牛帮我优化一下我的代码结构!谢谢啦!

1.FILENAME.php

<?php 
/**
  *
  * @author 冷流云 
  * @param 新浪微博 http://weibo.com/130326007
  */
 
function getLower($data){
    $length = strlen($data)-1;
    $str = &#39;&#39;;
    for ($i=0;$i<$length;$i++){
        $flag = true;
        if(!isUpper($data[$i])){//当前为小写 成立
            if($i == 3){
                $flag = getFlag($data,$i);
                //如果后第四个是大写 不成立
                if(isUpper($data[$i+4])){
                    $flag = false;
                }
            }else if($i == $length-3){
                $flag = getFlag($data,$i);
                //如果前第四个是大写 不成立
                if(isUpper($data[$i-4])){
                    $flag = false;
                }
            }else if($i>3 && $i<$length-3){
                $flag = getFlag($data,$i);
                //如果前||后第四个有一个是大写就不成立
                if(isUpper($data[$i+4]) || isUpper($data[$i-4])){
                    $flag = false;
                }
            }else{
                $flag = false;
            }
            if($flag){
                @$str .= $data[$i];
            }
        }
    }
    return $str;
}
//公共当前字符的前三后和三个
function getFlag($data,$i){
    $flag = true;
    for($j=$i-3;$j<=$i+3;$j++){
        if($j != $i){
            //如果有一个是小写就不成立
            if(!isUpper($data[$j])){
                $flag = false;
            }
        }
    }
    return $flag;
}
/**
 * 
 * 判断是否是大写字母
 */
function isUpper($s){
    if(@ord($s) < 97){
        return true;
    }else{
        return false;
    }
}
$res = &#39;&#39;;
$handle = fopen("./input.txt",&#39;r&#39;);
$d = fread($handle,filesize("./input.txt"));
$res = getlower(str_replace("\r\n","",$d));
/*while(!feof($handle)){//逐行读取方法
    $buffer = fgets($handle,4096);
    $res .= getlower($buffer);
}*/
echo $res;
fclose($handle);
?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools