Found matches:
177|RC456456456|54156456465|129$
show code
<?php
$contents = '175|RC456456456|54156456465|109$
176|RC456456456|54156456465|177$
177|RC456456456|54156456465|129$
178|RC456456456|54156456465|129$';
$searchfor = '177';
// escape special characters in the query
$pattern = preg_quote($searchfor, '/');
// finalise the regular expression, matching the whole line
$pattern = "/^$pattern.*?\$/m";
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
echo "Found matches:\n";
echo implode("\n", $matches[0]);
}
else{
echo "No matches found";
}