I want to setup some 301 redirects and the easiest option seems to be to use PHP for each page i need to redirect. I am doing this to try and keep search engine rankings which is why im using 301

Would the following be sufficent for a 301 redirect bearing in mind I want to keep google rankings??

PHP Code:
"HTTP/1.1 301 Moved Permanently" );
Header"Location: http://www.new-url.com" );