Здравствуйте, Finrod
вариант функции в стиле C
Приложение:
<?php
function get_str_nums($file_name, $fragment)
{
//open file for reading only; place the file pointer at the beginning of the file
$file_handle = fopen($file_name, "r");
//error if can't open file
if ( $file_handle == false )
exit("unable to open file $file_name :(");
//$i value at first iteration must be 0
$i = -1;
//while not end of file
while ( !feof($file_handle) )
{
$i++;
//read next string from file
$str = fgets($file_handle, 1024);
//if $fragment position into $str is identical to 0
//it is equal to 0 and they are of the same integer type
if ( strpos($str, $fragment) === 0 )
{
//add current string number to the result array
$result[] = $i;
}
}
//close file
fclose($file_handle);
return $result;
}
//---------------------------------------
$arr = get_str_nums("179225.txt", "Ст");
//print all elements of $arr
foreach ( $arr as $num )
{
echo $num."
";
}
?>