(1) There's an error in the loop test: you have '=' (assignment!) when clearly you should have '<'.
(2) There's a missing closing brace before the 'else'.
(3) Since there's no alpha chars in the pattern to match, you don't need eregi(), plain ereg() will do.
(4) Finally, ereg() doesn't work the way you apparently think it does: what shows up in the results array is [0] contains the entire string, [1] contains the results of matching the first parenthesized expression, [2] the second, and so on. In any case, each parenthesized sub-pattern will match only one substring of the target string.
All is not lost, however--the PCRE functions will do what you want:
if ($n = preg_match_all( '/\$[0-9]+.[0-9]+/', $contents, $cost ))
{
for ($i = 0; $i < $n; $i++ )
echo $cost[0][$i] . '<br>';
}
...