亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP 不與 arraypart 進行比較

PHP 不與 arraypart 進行比較

PHP
POPMUISE 2022-12-11 10:41:13
我正在創建一個簡單的腳本,它在文本文件中搜索正確的組合,但它不起作用。我對所有問題都進行了故障排除,但所有部分都可以正常工作,但整個腳本仍然無法正常工作,我不知道如何修復它。代碼:<html><form><input type="text" name="input" placeholder="hash"><button type="submit">Crack!</button></form><?php$input = $_GET["input"]; // pulling input from url$hashes = file_get_contents("hashes.txt"); // loading hashes$hasharray = explode(";", $hashes); // separating hashcombos$arraynum = count($hasharray); // counting number of hashcombos// defining loop$loopnum = 0;while($loopnum < $arraynum) {    $combo = $hasharray[$loopnum]; // selecting hashcombo    $comboarray = explode("|", $combo); // separating hashcombo    $text = $comboarray[0];    $hash = $comboarray[1];    // cecking if hash matches    if($hash === $input) {        echo("Hash: $hash");        echo("<br>");        echo("Text: $text");    }    $loopnum = $loopnum + 1; // updating loop}?></html>示例 hashes.txt:test|example;example|test;
查看完整描述

1 回答

?
揚帆大魚

TA貢獻1799條經驗 獲得超9個贊

您的文件包含換行符,它們也是不可見的字符。例如:

test|example;(newline here)
example|test;

您使用 拆分文件中的行;,但這不會刪除換行符??紤]到您問題中的評論,您的結果中有換行符導致比較失敗。也就是說,我建議在加載哈希以刪除換行符后立即使用以下解決方案:

$hashes = preg_replace("/[\r\n]/", "", $hashes);

這將產生如下字符串:

test|example;example|test;

您的其余代碼將按預期工作。


查看完整回答
反對 回復 2022-12-11
  • 1 回答
  • 0 關注
  • 101 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號