'; $f = fopen( $file, 'r ' ); while( ($ch = fgetc( $f )) != -1 ) { if ( $ch == '$' ){ $count = false; } if ( $count == true) { $counts .= $ch; } else { $old_day .= $ch; } } str_replace( '$', '', $old_day ); echo ' '.$counts.' '.$old_day; if ( $old_day == $day ) { $counts ; } else { $counts = 0; } fwrite( $f, $counts.'$'.$day ); fclose( $f ); } ?>