在以下代码中:
// array source elements are formatted like...
// string=string
// string string=string
foreach ($matches[0] as $value){
$titleText = array(); // Store results into an array.
foreach ($lines as $line) { // Read the lines in the dictionary file
if ( stripos($line, "<beginning of a line>" . $value . "=") || stripos($line, " " . $value . "=") !== false){ // Found string in array.
list($field1, $field2) = explode('=', $line);
array_push($titleText, "$field1 > $field2"); // Store all finds in array before outputting.
}
}
echo "Found " . count($titleText) . " instances of " . $value . "\n";
print_r($titleText);
}
我试图让 stripos() 识别一行的开头,这里......
if ( stripos($line, "<beginning of a line>" . $value . "=") || stripos($line, " " . $value . "=") !== false)
...但无法弄清楚这是否可能。有没有一种使用 stripos 的方法,或者可能有另一个功能可以做得更好。我最初选择 stripos 是因为阵列非常大,而 stripos 的本意是最快/最少的资源密集型。
谢谢。