Remove Spaces(PHP)

Discussion in 'Coding Help' started by ziycon, Oct 8, 2010.

  1. ziycon

    ziycon New Member

    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" />

  2. Forbairt

    Forbairt Portfolio Building

  3. ziycon

    ziycon New Member

    Don't think so as when you get down to the down of the site, there is indentation for DIVs etc which I want to keep?!
  4. Forbairt

    Forbairt Portfolio Building

    bit confused so ... you want to remove the white space but you don't want to remove the white space ? :D
  5. louie

    louie 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);

Share This Page