第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

兩個字符串相同,但比較時不相等

兩個字符串相同,但比較時不相等

PHP
翻翻過去那場雪 2022-10-28 14:57:24
我有一個我自己無法解決的小問題,我正在比較兩個相同的字符串,一個來自數(shù)據(jù)庫,另一個來自文本文件,除了最后一個之外,值總是相等的文本文件中的數(shù)組代碼while (!feof($monfichier)) {    $line = fgets($monfichier);    $pieces = explode(" ", $line);    $factureAgent[$nbb][0] = $pieces[0]; //id client    $factureAgent[$nbb][1] = $pieces[1]; //consommation annuelle    $factureAgent[$nbb][2] = $pieces[2]; //année    $factureAgent[$nbb][3] = $pieces[3]; //id agent    $month = explode(":", $pieces[4]);    $factureAgent[$nbb][4] = $month[1]; //janvier    $month = explode(":", $pieces[5]);    $factureAgent[$nbb][5] = $month[1]; //fevrier    $month = explode(":", $pieces[6]);    $factureAgent[$nbb][6] = $month[1]; //mars    $month = explode(":", $pieces[7]);    $factureAgent[$nbb][7] = $month[1]; //avril    $month = explode(":", $pieces[8]);    $factureAgent[$nbb][8] = $month[1]; //mai    $month = explode(":", $pieces[9]);    $factureAgent[$nbb][9] = $month[1]; //juin    $month = explode(":", $pieces[10]);    $factureAgent[$nbb][10] = $month[1]; //juillet    $month = explode(":", $pieces[11]);    $factureAgent[$nbb][11] = $month[1]; //aout    $month = explode(":", $pieces[12]);    $factureAgent[$nbb][12] = $month[1]; //septembre    $month = explode(":", $pieces[13]);    $factureAgent[$nbb][13] = $month[1]; //octobre    $month = explode(":", $pieces[14]);    $factureAgent[$nbb][14] = $month[1]; //novembre    $month = explode(":", $pieces[15]);    $factureAgent[$nbb][15] = $month[1]; //decembre    $nbb++;}這是代碼echo "<br>".$row[0]."is".$factureAgent[$i][$nb]."<br>";if ($année==$annéeComp[0]) {  if ($row[0]!=$factureAgent[$i][$nb]) {    echo "<br>".$row[0]."is".$factureAgent[$i][$nb]."<br>";    $ok = false;  }  $nb++;  $nbr++;}輸出25is2550is5087is87115is115200is200250is250400is400550is500600is600650is650800is800950is950950is950看圖片我正在從文本文件中讀取的行1 2000 2019 1 01:25 02:50 03:87 04:115 05:200 06:250 07:400 08:550 09:600 10:650 11:800 12:95013 2000 2019 1 01:45 02:90 03:150 04:300 05:600 06:800 07:1000 08:1300 09:1450 10:1600 11:1800 12:2000看圖片
查看完整描述

2 回答

?
幕布斯7119047

TA貢獻1794條經(jīng)驗 獲得超8個贊

比較來自不同來源的字符串可能會導(dǎo)致意外結(jié)果。

您可以做的一件事是將您的值轉(zhuǎn)換為相同的類型,然后進行比較。例如:

if (intval('1') === intval('01')) ...

這樣你就可以得到整數(shù)的兩側(cè),它只是一個整數(shù)比較。

請注意,如果您轉(zhuǎn)換一個非數(shù)字的值,該函數(shù)將始終返回 0


查看完整回答
反對 回復(fù) 2022-10-28
?
炎炎設(shè)計

TA貢獻1808條經(jīng)驗 獲得超4個贊

那可能是您使用==而不是===. 如果您不想考慮案例,我可能會建議使用strcasecmp,或者strcmp如果您希望考慮案例,我可能會建議使用。

strcasecmp()

strcmp()

注意將這些函數(shù)的結(jié)果與 0 進行比較,===以確保它們相等,例如: if (strcmp('Hello, 'Hello') === 0) ...

使用時要注意=====

(1 == '1') //Equal -- not taking into consideration the type but just the value

(1 === '1') //Not equal -- taking into consideration the type and the value

僅供您參考,不供您使用!=!==


查看完整回答
反對 回復(fù) 2022-10-28
  • 2 回答
  • 0 關(guān)注
  • 214 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號