Remove Spaces(PHP)

Advert test
I have source code thats generated by php then stored in a variable and echoed out. I want to remove the whitespace at the begining of every line but unsure how to go about it, any ideas?
<?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
        <html xmlns="" xml:lang="en" lang="en">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="robots" content="noindex,nofollow" />
        <meta name="googlebot" content="noarchive" />


New Member
$var = trim($var); // should do the trick removing white spaces at the beginning & end of the string
//another option is preg_replace - but removes anything that you are telling it to... (in this case white spaces...)
$var = preg_replace("#\s+#","",$var);