HELP my car is acting funny

last night i was driving my car and it started revving up on its own and not shifting properly when i go to slow down i press the brake and it still wants to keep going cause the engine is acting like i'm still pressing the gas when i shift into neutral the engine rev's up to about 4000 rpm for about 5-10 seconds then it kicks down and idles what the hell is causing this