次のコードでは:
// 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 を選択しました。
ありがとう。