所以我PHP精確搜索
$q = $_REQUEST["q"];
$f = fopen("address.txt", "r");
while (($line = fgets($f)) !== FALSE) {
if (strstr($line, $q)) {
print "<li>found: $line";
可以說我有
Street 1 number 122
Street 2 number 22
在
address.txt
,我想搜索的號碼22
。
如何搜索22
,而不是獲得122
也?
在此先感謝。
交從address.txt中..what一些示例文本是其對新行格式 –
每 街1號122 街2號22 街3號65 – qqq123
幼稚的解決辦法用空格包圍'$ q':'if(strstr($ line,'')。 $ q。 '「))' – Steve