Jump to content

Replacing Class Id With Id Contents


IanArcher

Recommended Posts

Hi, i am new to PHP but i have some common knowledge to recognizing commands and such. in my page i have code like this

<div class="page_column page_column_first" id="page_column_1" style="width: 499px;"><div class="page_block_container" id="page_block_759"><div class="disignBoxFirst">    <div class="boxFirstHeader"><div class="dbTitle">Up and Coming</div></div>    <div class="boxContent"><div class="dbContentHtml"><p>This is a placeholder for up and coming news to be edited at News Time.</p></div></div>

So whatever class it is linked to say "boxContent" which is the name of a section on a .css file on the server, i want it take the information under that header and place it on that same line and doing something like

preg_replace

class="boxContent with style="border: 0px; background-color: transparent; margin:10px auto 5px;" Can somebody write something like that for me please or help me with it? It's basically taking the css rule and converting it to inline Thanks

Link to comment
Share on other sites

That's not a trivial thing to do. Step 1 is to find all of the CSS files or inline rules, and parse the CSS to find the selectors and styles. Step 2 is the fun business of figuring out which selectors apply to any given element, and step 3 is adding the inline style to the element.

Link to comment
Share on other sites

That's not a trivial thing to do. Step 1 is to find all of the CSS files or inline rules, and parse the CSS to find the selectors and styles. Step 2 is the fun business of figuring out which selectors apply to any given element, and step 3 is adding the inline style to the element.
How can i do that? With DOMDocument possibly? Can you write me a sample of that please?
Link to comment
Share on other sites

It's far beyond your level. Is there any good reason why you want to do that?The DOMDocument is an built-in XML parser. PHP doesn't have a CSS parser, so you would have to build it yourself and that's not a trivial thing to do.

Link to comment
Share on other sites

It's far beyond your level. Is there any good reason why you want to do that?The DOMDocument is an built-in XML parser. PHP doesn't have a CSS parser, so you would have to build it yourself and that's not a trivial thing to do.
This is for sending a webpages URL in input through e-mail so it has to be in-line styles. Can you help me with this please?
Link to comment
Share on other sites

It might be easier for you to modify your pages manually for the e-mail.If you want somebody else to do it for you, it's not going to be free. If you want to do it yourself, you're going to have to make a program following the steps that justsomeguy gave you earlier. To find all the rules and parse them, you'll need to work with algorithms to analyze the string character by character to extract tokens and symbols. The next step is making the program know what to do with each selector and finally you have to add attributes to the elements that the selectors refer to.

Link to comment
Share on other sites

It sounds like an interesting problem, but I don't have time to do this for you. This might take me around 100 hours to finish and I've got enough on my plate already. You may want to look into purchasing software that does this.

Link to comment
Share on other sites

Well i came across an open source code that does this

<?php/** * CSS to Inline Styles class * * This source file can be used to convert HTML with CSS into HTML with inline styles * * Known issues: * - no support for pseudo selectors * * The class is documented in the file itself. If you find any bugs help me out and report them. Reporting can be done by sending an email to php-css-to-inline-styles-bugs[at]verkoyen[dot]eu. * If you report a bug, make sure you give me enough information (include your code). * * Changelog since 1.0.2 * - .class are matched from now on. * - fixed issue with #id * - new beta-feature: added a way to output valid XHTML (thx to Matt Hornsby) * * Changelog since 1.0.1 * - fixed some stuff on specifity * * Changelog since 1.0.0 * - rewrote the buildXPathQuery-method * - fixed some stuff on specifity * - added a way to use inline style-blocks * * License * Copyright (c) 2010, Tijs Verkoyen. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. * * This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. * * @author        Tijs Verkoyen <php-css-to-inline-styles@verkoyen.eu> * @version        1.0.3 * * @copyright    Copyright (c) 2010, Tijs Verkoyen. All rights reserved. * @license        BSD License */class CSSToInlineStyles{    /**     * The CSS to use     *     * @var    string     */    private $css;    /**     * The processed CSS rules     *     * @var    array     */    private $cssRules;    /**     * Should the generated HTML be cleaned     *     * @var    bool     */    private $cleanup = false;    /**     * The HTML to process     *     * @var    string     */    private $html;    /**     * Use inline-styles block as CSS     *     * @var    bool     */    private $useInlineStylesBlock = false;    /**     * Creates an instance, you could set the HTML and CSS here, or load it later.     *     * @return    void     * @param    string[optional] $html    The HTML to process     * @param    string[optional] $css    The CSS to use     */    public function __construct($html = "http://test2.chamberhome.com/viewPage.php?ID=Newsletter_1",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/common.css",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/general.css",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/anchor.css",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/forms_adv.css",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/login_form.css",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/top_menu.css",$css = "http://test2.chamberhome.com/templates/tmpl_uni/css/BxCustomProfileMenu.css",$css = "http://test2.chamberhome.com/modules/boonex/listings/templates/base/css/unit.css",$css = "http://test2.chamberhome.com/modules/boonex/groups/templates/base/css/unit.css",$css = "http://test2.chamberhome.com/modules/boonex/videos/templates/base/css/search.css",$css = "http://test2.chamberhome.com/modules/boonex/sites/templates/base/css/main.css",$css = "http://test2.chamberhome.com/modules/boonex/poll/templates/base/css/main.css",$css = "http://test2.chamberhome.com/modules/boonex/news/templates/base/css/view.css",$css = "http://test2.chamberhome.com/modules/boonex/articles/templates/base/css/view.css",$css = "http://test2.chamberhome.com/modules/boonex/quotes/templates/base/css/unit.css")        {        if($html !== null) $this->setHTML($html);        if($css !== null) $this->setCSS($css);    }    /**     * Convert a CSS-selector into an xPath-query     *     * @return    string     * @param    string $selector    The CSS-selector     */    private function buildXPathQuery($selector)    {        // redefine        $selector = (string) $selector;        // the CSS selector        $cssSelector = array(    '/(\w)\s+(\w)/',                // E F                Matches any F element that is a descendant of an E element                                '/(\w)\s*>\s*(\w)/',            // E > F            Matches any F element that is a child of an element E                                '/(\w):first-child/',            // E:first-child    Matches element E when E is the first child of its parent                                '/(\w)\s*\+\s*(\w)/',            // E + F            Matches any F element immediately preceded by an element                                '/(\w)\[([\w\-]+)]/',            // E[foo]            Matches any E element with the "foo" attribute set (whatever the value)                                '/(\w)\[([\w\-]+)\=\"(.*)\"]/',    // E[foo="warning"]    Matches any E element whose "foo" attribute value is exactly equal to "warning"                                '/(\w+|\*)+\.([\w\-]+)+/',        // div.warning        HTML only. The same as DIV[class~="warning"]                                '/\.([\w\-]+)/',                // .warning            HTML only. The same as *[class~="warning"]                                '/(\w+)+\#([\w\-]+)/',            // E#myid            Matches any E element with id-attribute equal to "myid"                                '/\#([\w\-]+)/'                    // #myid            Matches any element with id-attribute equal to "myid"                            );        // the xPath-equivalent        $xPathQuery = array(    '\1//\2',                                                                        // E F                Matches any F element that is a descendant of an E element                                '\1/\2',                                                                        // E > F            Matches any F element that is a child of an element E                                '*[1]/self::\1',                                                                // E:first-child    Matches element E when E is the first child of its parent                                '\1/following-sibling::*[1]/self::\2',                                            // E + F            Matches any F element immediately preceded by an element                                '\1 [ @\2 ]',                                                                    // E[foo]            Matches any E element with the "foo" attribute set (whatever the value)                                '\1[ contains( concat( " ", @\2, " " ), concat( " ", "\3", " " ) ) ]',            // E[foo="warning"]    Matches any E element whose "foo" attribute value is exactly equal to "warning"                                '\1[ contains( concat( " ", @class, " " ), concat( " ", "\2", " " ) ) ]',        // div.warning        HTML only. The same as DIV[class~="warning"]                                '*[ contains( concat( " ", @class, " " ), concat( " ", "\1", " " ) ) ]',        // .warning            HTML only. The same as *[class~="warning"]                                '\1[ @id = "\2" ]',                                                                // E#myid            Matches any E element with id-attribute equal to "myid"                                '*[ @id = "\1" ]'                                                                // #myid            Matches any element with id-attribute equal to "myid"                            );        // return        return (string) '//'. preg_replace($cssSelector, $xPathQuery, $selector);    }    /**     * Calculate the specifity for the CSS-selector     *     * @return    int     * @param    string $selector     */    private function calculateCSSSpecifity($selector)    {        // cleanup selector        $selector = str_replace(array('>', '+'), array(' > ', ' + '), $selector);        // init var        $specifity = 0;        // split the selector into chunks based on spaces        $chunks = explode(' ', $selector);        // loop chunks        foreach($chunks as $chunk)        {            // an ID is important, so give it a high specifity            if(strstr($chunk, '#') !== false) $specifity += 100;            // classes are more important than a tag, but less important then an ID            elseif(strstr($chunk, '.')) $specifity += 10;            // anything else isn't that important            else $specifity += 1;        }        // return        return $specifity;    }    /**     * Cleanup the generated HTML     *     * @return    string     * @param    string $html    The HTML to cleanup     */    private function cleanupHTML($html)    {        // remove classes        $html = preg_replace('/(\s)+class="(.*)"(\s)+/U', ' ', $html);        // remove IDs        $html = preg_replace('/(\s)+id="(.*)"(\s)+/U', ' ', $html);        // return        return $html;    }    /**     * Converts the loaded HTML into an HTML-string with inline styles based on the loaded CSS     *     * @return    string     * @param    bool $outputXHTML    Should we output valid XHTML?     */    public function convert($outputXHTML = false)    {        // redefine        $outputXHTML = (bool) $outputXHTML;        // validate        if($this->html == null) throw new CSSToInlineStylesException('No HTML provided.');        // should we use inline style-block        if($this->useInlineStylesBlock)        {            // init var            $matches = array();            // match the style blocks            preg_match_all('|<style(.*)>(.*)</style>|isU', $this->html, $matches);            // any style-blocks found?            if(!empty($matches[2]))            {                // add                foreach($matches[2] as $match) $this->css .= trim($match) ."\n";            }        }        // process css        $this->processCSS();        // create new DOMDocument        $document = new DOMDocument('MaxPHP.php');        // set error level        libxml_use_internal_errors(true);        // load HTML        $document->loadHTML($this->html);        // create new XPath        $xPath = new DOMXPath($document);        // any rules?        if(!empty($this->cssRules))        {            // loop rules            foreach($this->cssRules as $rule)            {                // init var                $query = $this->buildXPathQuery($rule['selector']);                // validate query                if($query === false) continue;                // search elements                $elements = $xPath->query($query);                // validate elements                if($elements === false) continue;                // loop found elements                foreach($elements as $element)                {                    // init var                    $properties = array();                    // get current styles                    $stylesAttribute = $element->attributes->getNamedItem('style');                    // any styles defined before?                    if($stylesAttribute !== null)                    {                        // get value for the styles attribute                        $definedStyles = (string) $stylesAttribute->value;                        // split into properties                        $definedProperties = (array) explode(';', $definedStyles);                        // loop properties                        foreach($definedProperties as $property)                        {                            // validate property                            if($property == '') continue;                            // split into chunks                            $chunks = (array) explode(':', trim($property), 2);                            // validate                            if(!isset($chunks[1])) continue;                            // loop chunks                            $properties[$chunks[0]] = trim($chunks[1]);                        }                    }                    // add new properties into the list                    foreach($rule['properties'] as $key => $value) $properties[$key] = $value;                    // build string                    $propertyChunks = array();                    // build chunks                    foreach($properties as $key => $value) $propertyChunks[] = $key .': '. $value .';';                    // build properties string                    $propertiesString = implode(' ', $propertyChunks);                    // set attribute                    if($propertiesString != '') $element->setAttribute('style', $propertiesString);                }            }        }        // should we output XHTML?        if($outputXHTML)        {            // set formating            $document->formatOutput = true;            // get the HTML as XML            $html = $document->saveXML(null, LIBXML_NOEMPTYTAG);        }        // just regular HTML 4.01 as it should be used in newsletters        else        {            // get the HTML            $html = $document->saveHTML();        }        // cleanup the HTML if we need to        if($this->cleanup) $html = $this->cleanupHTML($html);        // return        return $html;    }    /**     * Process the loaded CSS     *     * @return    void     */    private function processCSS()    {        // init vars        $css = (string) $this->css;        // remove newlines        $css = str_replace(array("\r", "\n"), '', $css);        // replace double quotes by single quotes        $css = str_replace('"', '\'', $css);        // remove comments        $css = preg_replace('|/\*.*?\*/|', '', $css);        // remove spaces        $css = preg_replace('/\s\s+/', ' ', $css);        // rules are splitted by }        $rules = (array) explode('}', $css);        // init var        $i = 1;        // loop rules        foreach($rules as $rule)        {            // split into chunks            $chunks = explode('{', $rule);            // invalid rule?            if(!isset($chunks[1])) continue;            // set the selectors            $selectors = trim($chunks[0]);            // get cssProperties            $cssProperties = trim($chunks[1]);            // split multiple selectors            $selectors = (array) explode(',', $selectors);            // loop selectors            foreach($selectors as $selector)            {                // cleanup                $selector = trim($selector);                // build an array for each selector                $ruleSet = array();                // store selector                $ruleSet['selector'] = $selector;                // process the properties                $ruleSet['properties'] = $this->processCSSProperties($cssProperties);                // calculate specifity                $ruleSet['specifity'] = $this->calculateCSSSpecifity($selector);                // add into global rules                $this->cssRules[] = $ruleSet;            }            // increment            $i++;        }        // sort based on specifity        if(!empty($this->cssRules)) usort($this->cssRules, array('CSSToInlineStyles', 'sortOnSpecifity'));    }    /**     * Process the CSS-properties     *     * @return    array     * @param    string $propertyString     */    private function processCSSProperties($propertyString)    {        // split into chunks        $properties = (array) explode(';', $propertyString);        // init var        $pairs = array();        // loop properties        foreach($properties as $property)        {            // split into chunks            $chunks = (array) explode(':', $property, 2);            // validate            if(!isset($chunks[1])) continue;            // add to pairs array            $pairs[trim($chunks[0])] = trim($chunks[1]);        }        // sort the pairs        ksort($pairs);        // return        return $pairs;    }    /**     * Should the IDs and classes be removed?     *     * @return    void     * @param    bool[optional] $on     */    public function setCleanup($on = true)    {        $this->cleanup = (bool) $on;    }    /**     * Set CSS to use     *     * @return    void     * @param    string $css        The CSS to use     */    public function setCSS($css)    {        $this->css = (string) $css;    }    /**     * Set HTML to process     *     * @return    void     * @param    string $html     */    public function setHTML($html)    {        $this->html = (string) $html;    }    /**     * Set use of inline styles block     * If this is enabled the class will use the style-block in the HTML.     *     * @param    bool[optional] $on     */    public function setUseInlineStylesBlock($on = true)    {        $this->useInlineStylesBlock = (bool) $on;    }    /**     * Sort an array on the specifity element     *     * @return    int     * @param    array $e1    The first element     * @param    array $e2    The second element     */    private static function sortOnSpecifity($e1, $e2)    {        // validate        if(!isset($e1['specifity']) || !isset($e2['specifity'])) return 0;        // lower        if($e1['specifity'] < $e2['specifity']) return -1;        // higher        if($e1['specifity'] > $e2['specifity']) return 1;        // fallback        return 0;    }}/** * CSSToInlineStyles Exception class * * @author    Tijs Verkoyen <php-css-to-inline-styles@verkoyen.eu> */class CSSToInlineStylesException extends Exception{}?>

Though i want it to display the finished product in the browser window and possibly output it to a file. I'm aware of fwrite and echo commands but i do not know which variables to begin with for this particular code Since everything is so specific.

Link to comment
Share on other sites

Check the bottom of the convert function, it will return the HTML that was generated. If you want to modify that function to also save a file, you can use this method: http://www.php.net/m...avehtmlfile.php Or, you can get the returned HTML and use file_put_contents to save it. I'm not sure if you modified that file at all, but it's got some problems. One is all of the duplicate $css variables that are in the constructor, and another is that a filename is being passed to the DOMDocument constructor, which is not correct.

Link to comment
Share on other sites

Check the bottom of the convert function, it will return the HTML that was generated. If you want to modify that function to also save a file, you can use this method: http://www.php.net/m...avehtmlfile.php Or, you can get the returned HTML and use file_put_contents to save it. I'm not sure if you modified that file at all, but it's got some problems. One is all of the duplicate $css variables that are in the constructor, and another is that a filename is being passed to the DOMDocument constructor, which is not correct.
I used file_put_contents and saveHTMLfile and none worked. Though now i am at
mb_convert_encoding("UTF-8", "UTF-8"); $file = fopen("finished.html","w");echo fwrite($file,"$html");fclose($file); 

But it returns the errorNotice: Undefined variable: html in C:\xampp\htdocs\mydiv\process.php on line 5540 I don't know which "$" variable to use for it to actually output. Also which $css duplicates can i get rid of without completely messing up the final code.

Link to comment
Share on other sites

I used file_put_contents and saveHTMLfile and none worked.
Those functions do actually work, believe it or not, so it sounds like you're doing something wrong.
mb_convert_encoding("UTF-8", "UTF-8"); $file = fopen("finished.html","w");echo fwrite($file,"$html");fclose($file);

That code converts the string "UTF-8" to be encoded as UTF-8, then you try to open and write to the file. The file_put_contents function is a replacement for fopen/fwrite/fclose, but if you would rather use those three then that will work also. You're trying to echo the result of fwrite though, so make sure you know what that function returns (it does not return the data you wrote): http://www.php.net/m...tion.fwrite.php It would help to try and find documentation for that class, but you would probably use it like this:

$converter = new CSSToInlineStyles($html_code, $css_code);$converter->setCleanup(true);$output = $converter->convert();

In that code, $html_code is the string of HTML code you start with, $css_code is the string of CSS code that applies to the HTML, and $output is the converted HTML. The constructor should be defined like this: public function __construct($html = null, $css = null) You do not need to edit anything in that file. In fact, if you edit anything in that file it's not going to work the same, it might not work at all. That includes the filename in the DOMDocument constructor inside the convert function. That code defines a class, when you use the class you pass all of the data that it needs, you don't need to edit the class with the data in it. If you edit the class then the class only works for one thing, if you pass the data to the class then you can use the class for anything.

Link to comment
Share on other sites

So sticking to the original code without having a filename in the construct and so onI am using this to input a URL: test2.chamberhome.com/viewPage.php?ID=Newsletter_1 and the CSS that the URL uses are multiple CSS files and not just one: test2.chamberhome.com/templates/tmpl_uni/css/common.css test2.chamberhome.com/templates/tmpl_uni/css/general.css test2.chamberhome.com/templates/tmpl_uni/css/anchor.css test2.chamberhome.com/templates/tmpl_uni/css/forms_adv.css test2.chamberhome.com/templates/tmpl_uni/css/login_form.css test2.chamberhome.com/templates/tmpl_uni/css/top_menu.css test2.chamberhome.com/templates/tmpl_uni/css/BxCustomProfileMenu.css test2.chamberhome.com/modules/boonex/listings/templates/base/css/unit.css test2.chamberhome.com/modules/boonex/groups/templates/base/css/unit.css test2.chamberhome.com/modules/boonex/videos/templates/base/css/search.css test2.chamberhome.com/modules/boonex/sites/templates/base/css/main.css test2.chamberhome.com/modules/boonex/poll/templates/base/css/main.css test2.chamberhome.com/modules/boonex/news/templates/base/css/view.css test2.chamberhome.com/modules/boonex/articles/templates/base/css/view.css test2.chamberhome.com/modules/boonex/quotes/templates/base/css/unit.css i removed the 'http://' for this post because it shortens the link. How would I be able to get my desired result? Btw, the documentation for this is located here: http://classes.verko...ine_styles/docsIf it may assist you in assisting me, i'm reading but i could use more professional help. I really appreciate your help so far.

Link to comment
Share on other sites

That class is only set up to process one CSS file, so you need to either get the code from all files and combine them, or run the converter once for each CSS file where you keep passing in the updated HTML code and the next CSS code. Note that this does not work with URLs, you need to pass it the actual code. You can get the code from a file using file_get_contents.

Link to comment
Share on other sites

That class is only set up to process one CSS file, so you need to either get the code from all files and combine them, or run the converter once for each CSS file where you keep passing in the updated HTML code and the next CSS code. Note that this does not work with URLs, you need to pass it the actual code. You can get the code from a file using file_get_contents.
You mean pass it the actual html code and css code? Btw, i copied all the code from all the css files into one called style.cssDo i copy all the html code and place it between $html = "<ALL MY HTML>" and then the $css = "style.css"Like so? As i am still receiving no error but it doesn't output a file it just shows up in the browser as these characters  i am using XAMPP by the way. Here is my current code:
<?php/** * CSS to Inline Styles class * * This source file can be used to convert HTML with CSS into HTML with inline styles * * Known issues: * - no support for pseudo selectors * * The class is documented in the file itself. If you find any bugs help me out and report them. Reporting can be done by sending an email to php-css-to-inline-styles-bugs[at]verkoyen[dot]eu. * If you report a bug, make sure you give me enough information (include your code). * * Changelog since 1.0.2 * - .class are matched from now on. * - fixed issue with #id * - new beta-feature: added a way to output valid XHTML (thx to Matt Hornsby) * * Changelog since 1.0.1 * - fixed some stuff on specifity * * Changelog since 1.0.0 * - rewrote the buildXPathQuery-method * - fixed some stuff on specifity * - added a way to use inline style-blocks * * License * Copyright (c) 2010, Tijs Verkoyen. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. * * This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. * * @author        Tijs Verkoyen <php-css-to-inline-styles@verkoyen.eu> * @version        1.0.3 * * @copyright    Copyright (c) 2010, Tijs Verkoyen. All rights reserved. * @license        BSD License */ class CSSToInlineStyles{    /**     * The CSS to use     *     * @var    string     */    private $css;    /**     * The processed CSS rules     *     * @var    array     */    private $cssRules;    /**     * Should the generated HTML be cleaned     *     * @var    bool     */    private $cleanup = false;    /**     * The HTML to process     *     * @var    string     */    private $html;    /**     * Use inline-styles block as CSS     *     * @var    bool     */    private $useInlineStylesBlock = false;    /**     * Creates an instance, you could set the HTML and CSS here, or load it later.     *     * @return    void     * @param    string[optional] $html    The HTML to process     * @param    string[optional] $css    The CSS to use     */        public function __construct($html = "chamber.html", $css = "style.css")        {        if($html !== null) $this->setHTML($html);        if($css !== null) $this->setCSS($css);    }    /**     * Convert a CSS-selector into an xPath-query     *     * @return    string     * @param    string $selector    The CSS-selector     */    private function buildXPathQuery($selector)    {        // redefine        $selector = (string) $selector;        // the CSS selector        $cssSelector = array(    '/(\w)\s+(\w)/',                // E F                Matches any F element that is a descendant of an E element                                '/(\w)\s*>\s*(\w)/',            // E > F            Matches any F element that is a child of an element E                                '/(\w):first-child/',            // E:first-child    Matches element E when E is the first child of its parent                                '/(\w)\s*\+\s*(\w)/',            // E + F            Matches any F element immediately preceded by an element                                '/(\w)\[([\w\-]+)]/',            // E[foo]            Matches any E element with the "foo" attribute set (whatever the value)                                '/(\w)\[([\w\-]+)\=\"(.*)\"]/',    // E[foo="warning"]    Matches any E element whose "foo" attribute value is exactly equal to "warning"                                '/(\w+|\*)+\.([\w\-]+)+/',        // div.warning        HTML only. The same as DIV[class~="warning"]                                '/\.([\w\-]+)/',                // .warning            HTML only. The same as *[class~="warning"]                                '/(\w+)+\#([\w\-]+)/',            // E#myid            Matches any E element with id-attribute equal to "myid"                                '/\#([\w\-]+)/'                    // #myid            Matches any element with id-attribute equal to "myid"                            );        // the xPath-equivalent        $xPathQuery = array(    '\1//\2',                                                                        // E F                Matches any F element that is a descendant of an E element                                '\1/\2',                                                                        // E > F            Matches any F element that is a child of an element E                                '*[1]/self::\1',                                                                // E:first-child    Matches element E when E is the first child of its parent                                '\1/following-sibling::*[1]/self::\2',                                            // E + F            Matches any F element immediately preceded by an element                                '\1 [ @\2 ]',                                                                    // E[foo]            Matches any E element with the "foo" attribute set (whatever the value)                                '\1[ contains( concat( " ", @\2, " " ), concat( " ", "\3", " " ) ) ]',            // E[foo="warning"]    Matches any E element whose "foo" attribute value is exactly equal to "warning"                                '\1[ contains( concat( " ", @class, " " ), concat( " ", "\2", " " ) ) ]',        // div.warning        HTML only. The same as DIV[class~="warning"]                                '*[ contains( concat( " ", @class, " " ), concat( " ", "\1", " " ) ) ]',        // .warning            HTML only. The same as *[class~="warning"]                                '\1[ @id = "\2" ]',                                                                // E#myid            Matches any E element with id-attribute equal to "myid"                                '*[ @id = "\1" ]'                                                                // #myid            Matches any element with id-attribute equal to "myid"                            );        // return        return (string) '//'. preg_replace($cssSelector, $xPathQuery, $selector);    }    /**     * Calculate the specifity for the CSS-selector     *     * @return    int     * @param    string $selector     */    private function calculateCSSSpecifity($selector)    {        // cleanup selector        $selector = str_replace(array('>', '+'), array(' > ', ' + '), $selector);        // init var        $specifity = 0;        // split the selector into chunks based on spaces        $chunks = explode(' ', $selector);        // loop chunks        foreach($chunks as $chunk)        {            // an ID is important, so give it a high specifity            if(strstr($chunk, '#') !== false) $specifity += 100;            // classes are more important than a tag, but less important then an ID            elseif(strstr($chunk, '.')) $specifity += 10;            // anything else isn't that important            else $specifity += 1;        }        // return        return $specifity;    }    /**     * Cleanup the generated HTML     *     * @return    string     * @param    string $html    The HTML to cleanup     */    private function cleanupHTML($html)    {        // remove classes        $html = preg_replace('/(\s)+class="(.*)"(\s)+/U', ' ', $html);        // remove IDs        $html = preg_replace('/(\s)+id="(.*)"(\s)+/U', ' ', $html);        // return        return $html;    }    /**     * Converts the loaded HTML into an HTML-string with inline styles based on the loaded CSS     *     * @return    string     * @param    bool $outputXHTML    Should we output valid XHTML?     */    public function convert($outputXHTML = false)    {        // redefine        $outputXHTML = (bool) $outputXHTML;        // validate        if($this->html == null) throw new CSSToInlineStylesException('No HTML provided.');        // should we use inline style-block        if($this->useInlineStylesBlock)        {            // init var            $matches = array();            // match the style blocks            preg_match_all('|<style(.*)>(.*)</style>|isU', $this->html, $matches);            // any style-blocks found?            if(!empty($matches[2]))            {                // add                foreach($matches[2] as $match) $this->css .= trim($match) ."\n";            }        }        // process css        $this->processCSS();        // create new DOMDocument        $document = new DOMDocument();        // set error level        libxml_use_internal_errors(true);        // load HTML        $document->loadHTML($this->html);        // create new XPath        $xPath = new DOMXPath($document);        // any rules?        if(!empty($this->cssRules))        {            // loop rules            foreach($this->cssRules as $rule)            {                // init var                $query = $this->buildXPathQuery($rule['selector']);                // validate query                if($query === false) continue;                // search elements                $elements = $xPath->query($query);                // validate elements                if($elements === false) continue;                // loop found elements                foreach($elements as $element)                {                    // init var                    $properties = array();                    // get current styles                    $stylesAttribute = $element->attributes->getNamedItem('style');                    // any styles defined before?                    if($stylesAttribute !== null)                    {                        // get value for the styles attribute                        $definedStyles = (string) $stylesAttribute->value;                        // split into properties                        $definedProperties = (array) explode(';', $definedStyles);                        // loop properties                        foreach($definedProperties as $property)                        {                            // validate property                            if($property == '') continue;                            // split into chunks                            $chunks = (array) explode(':', trim($property), 2);                            // validate                            if(!isset($chunks[1])) continue;                            // loop chunks                            $properties[$chunks[0]] = trim($chunks[1]);                        }                    }                    // add new properties into the list                    foreach($rule['properties'] as $key => $value) $properties[$key] = $value;                    // build string                    $propertyChunks = array();                    // build chunks                    foreach($properties as $key => $value) $propertyChunks[] = $key .': '. $value .';';                    // build properties string                    $propertiesString = implode(' ', $propertyChunks);                    // set attribute                    if($propertiesString != '') $element->setAttribute('style', $propertiesString);                }            }        }        // should we output XHTML?        if($outputXHTML)        {            // set formating            $document->formatOutput = true;            // get the HTML as XML            $html = $document->saveXML(null, LIBXML_NOEMPTYTAG);        }        // just regular HTML 4.01 as it should be used in newsletters        else        {            // get the HTML            $html = $document->saveHTML("finished.html");        }        // cleanup the HTML if we need to        if($this->cleanup) $html = $this->cleanupHTML($html);        // return        return $html;    }    /**     * Process the loaded CSS     *     * @return    void     */    private function processCSS()    {        // init vars        $css = (string) $this->css;        // remove newlines        $css = str_replace(array("\r", "\n"), '', $css);        // replace double quotes by single quotes        $css = str_replace('"', '\'', $css);        // remove comments        $css = preg_replace('|/\*.*?\*/|', '', $css);        // remove spaces        $css = preg_replace('/\s\s+/', ' ', $css);        // rules are splitted by }        $rules = (array) explode('}', $css);        // init var        $i = 1;        // loop rules        foreach($rules as $rule)        {            // split into chunks            $chunks = explode('{', $rule);            // invalid rule?            if(!isset($chunks[1])) continue;            // set the selectors            $selectors = trim($chunks[0]);            // get cssProperties            $cssProperties = trim($chunks[1]);            // split multiple selectors            $selectors = (array) explode(',', $selectors);            // loop selectors            foreach($selectors as $selector)            {                // cleanup                $selector = trim($selector);                // build an array for each selector                $ruleSet = array();                // store selector                $ruleSet['selector'] = $selector;                // process the properties                $ruleSet['properties'] = $this->processCSSProperties($cssProperties);                // calculate specifity                $ruleSet['specifity'] = $this->calculateCSSSpecifity($selector);                // add into global rules                $this->cssRules[] = $ruleSet;            }            // increment            $i++;        }        // sort based on specifity        if(!empty($this->cssRules)) usort($this->cssRules, array('CSSToInlineStyles', 'sortOnSpecifity'));    }    /**     * Process the CSS-properties     *     * @return    array     * @param    string $propertyString     */    private function processCSSProperties($propertyString)    {        // split into chunks        $properties = (array) explode(';', $propertyString);        // init var        $pairs = array();        // loop properties        foreach($properties as $property)        {            // split into chunks            $chunks = (array) explode(':', $property, 2);            // validate            if(!isset($chunks[1])) continue;            // add to pairs array            $pairs[trim($chunks[0])] = trim($chunks[1]);        }        // sort the pairs        ksort($pairs);        // return        return $pairs;    }    /**     * Should the IDs and classes be removed?     *     * @return    void     * @param    bool[optional] $on     */    public function setCleanup($on = true)    {        $this->cleanup = (bool) $on;    }    /**     * Set CSS to use     *     * @return    void     * @param    string $css        The CSS to use     */    public function setCSS($css)    {        $this->css = (string) $css;    }    /**     * Set HTML to process     *     * @return    void     * @param    string $html     */    public function setHTML($html)    {        $this->html = (string) $html;    }    /**     * Set use of inline styles block     * If this is enabled the class will use the style-block in the HTML.     *     * @param    bool[optional] $on     */    public function setUseInlineStylesBlock($on = true)    {        $this->useInlineStylesBlock = (bool) $on;    }    /**     * Sort an array on the specifity element     *     * @return    int     * @param    array $e1    The first element     * @param    array $e2    The second element     */    private static function sortOnSpecifity($e1, $e2)    {        // validate        if(!isset($e1['specifity']) || !isset($e2['specifity'])) return 0;        // lower        if($e1['specifity'] < $e2['specifity']) return -1;        // higher        if($e1['specifity'] > $e2['specifity']) return 1;        // fallback        return 0;    }}/** * CSSToInlineStyles Exception class * * @author    Tijs Verkoyen <php-css-to-inline-styles@verkoyen.eu> */class CSSToInlineStylesException extends Exception{}mb_convert_encoding("UTF-8", "UTF-8");?>

Link to comment
Share on other sites

You edited the code again, don't change the __construct function. Look at the example from the documentation:

<?php// requirerequire_once 'css_to_inline_styles.php';// create instance$cssToInlineStyles = new CSSToInlineStyles('<the-html-to-process-as-a-string>', '<the-css-to-use>');// grab the processed HTML$processedHTML = $cssToInlineStyles->convert();?>

That code passes the HTML code and CSS code that you see in the middle line into the constructor, that's how the constructor gets that data. You shouldn't edit the constructor directly, you pass the data to it. It was already set up to receive the data before you changed it. Again, you don't need to edit the files he gave you at all. The first line in the example includes the class definition file that you're posting. Your code should include that file, create a new converter object, and run the converter like the example above shows. The only thing you need to add is where you get your HTML and CSS code, and you can use the file_get_contents function that I linked to in the last post. Look at the examples on that page. The code does expect the actual HTML and CSS code, not the filenames. If you want the converter to also remove the IDs and classes, then you need to use the setCleanup function like I showed in post 11.

Link to comment
Share on other sites

So, this is where i'm at. This is converter.php. process.php is what is known as css_to_inline_styles.php Now with the file get contents i know it's wrong because of the error messages i keep getting,Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\xampp\htdocs\mydiv\converter.php on line 6 then there's the last part, writing the finished product to a file.

<?php// requirerequire_once 'process.php'; // create instance$cssToInlineStyles = new CSSToInlineStyles ( (file_get_contents 'chamber.html', 'style.css') ); $cssToInlineStyles->setCleanup(true); // grab the processed HTML$processedHTML = $cssToInlineStyles->convert();   ?>

Link to comment
Share on other sites

$cssToInlineStyles = new CSSToInlineStyles ( file_get_contents('chamber.html'), file_get_contents('style.css') ); For saving the data, you can use file_put_contents. http://www.php.net/m...ut-contents.php
Thanks a million, you really helped me, it worked just like i'd hoped.
<?php// requirerequire_once 'process.php'; //Captures URL and Outputs it to a file that will be used for the conversion$url = file_get_contents('http://test2.chamberhome.com/viewPage.php?ID=Newsletter_1');file_put_contents('chamber.html', $url);				// create instance$cssToInlineStyles = new CSSToInlineStyles ( file_get_contents('chamber.html'), file_get_contents('style.css') ); //Removes IDs and Classes$cssToInlineStyles->setCleanup(false); // grab the processed HTML$processedHTML = $cssToInlineStyles->convert(); //Removes links and script tags that emails don't support$data = str_replace('</a>', '', $processedHTML);$data = preg_replace('/<a[^>]+href[^>]+>/', '', $processedHTML); //Convert character encoding to UTF-8mb_convert_encoding('', "UTF-8"); //Displays Finished Result in Browserecho $processedHTML; //Outputs finished result to filefile_put_contents('finished.html', $processedHTML); ?>

The removing of <a href> tags and <script tags> aren't working really.http://1svi.com/mydiv/finished.html <=== You can see the finished result there. I also need to remove the top menu bar and everything that's in it. I think you call those children (<div class ="sys_top_menu">) and (<div class="sys_breadcrumb">) and it's children. I thought the preg_replace or strip_tags functions would work but they're not doing the job.Here's a snippet of those classes and there children. http://codepad.org/LwZZ0b91 You also mentioned repeating the process for the multiple CSS files instead of one? Reason i bring this up is because of when i combined them now the finished product (I uploaded for you to see, the main banner in the page is to the left instead of centered.) Edit: i managed to work around getting <a href> tags removed, repositioned the banner somehow. Though i still would need to strip those parent and child <div> and using multiple CSS as you mentioned. I know you said you have alot on your plate and i want to get out of your hair, could you assist me in this last part please?

Link to comment
Share on other sites

Removing those elements is basically out of the scope of regular expressions. You may need to load the HTML into something like a DOMDocument object that will actually parse the HTML and let you access the individual elements. A more complex way would be to parse the HTML yourself and counting how many nested divs there are to figure out how much text to remove. Other than that, you probably also want to strip out all comments, all script tags and event handlers, and all link tags. The text that goes to the mail client shouldn't have any Javascript or links to online resources like CSS files.

Link to comment
Share on other sites

Removing those elements is basically out of the scope of regular expressions. You may need to load the HTML into something like a DOMDocument object that will actually parse the HTML and let you access the individual elements. A more complex way would be to parse the HTML yourself and counting how many nested divs there are to figure out how much text to remove. Other than that, you probably also want to strip out all comments, all script tags and event handlers, and all link tags. The text that goes to the mail client shouldn't have any Javascript or links to online resources like CSS files.
Some of it will have to be removed manually. How can i remove the <link> tags now? I've been using strip_tags, preg_replace and str_replace and nothing works. Even with the [^>] for the spaces.
Link to comment
Share on other sites

I've been using strip_tags, preg_replace and str_replace and nothing works.
You phrase that like the functions are broken or something. If you try something and it doesn't do what you expect, consider that maybe you're just not using it correctly. If you want to post the code you tried then we can point out why it didn't do what you expected. Your code examples in this thread have had errors in them, so don't assume that you're writing error-free code and the functions are just broken. I would use preg_replace for removing individual tags: $html = preg_replace('#<link [^>]*>#i', '', $html);
Link to comment
Share on other sites

You phrase that like the functions are broken or something. If you try something and it doesn't do what you expect, consider that maybe you're just not using it correctly. If you want to post the code you tried then we can point out why it didn't do what you expected. Your code examples in this thread have had errors in them, so don't assume that you're writing error-free code and the functions are just broken. I would use preg_replace for removing individual tags: $html = preg_replace('#<link [^>]*>#i', '', $html);
You were also talking about using the function over and over again to convert all the css files. How would a code like that look?Here is my code as of now:
<?php// requirerequire_once 'process.php';//Captures URL and Outputs it to a file that will be used for the conversion$url = file_get_contents('http://test2.chamberhome.com/viewPage.php?ID=Newsletter_1');//Stripping ahead$url = str_replace('</a>', '', $url);$url = str_replace('/<div[^>]+class="sys_top_menu"[^>]+style="background:[^>]+transparent[^>]+url(../images/tm_bg.png)[^>]+repeat-x[^>]+scroll[^>]+center[^>]+top;[^>]+min-height:[^>]+31px;[^>]+position:[^>]+relative;[^>]+z-index:[^>]+100;"[^>]+>/', '', $url);$url = preg_replace('/<a[^>]+href[^>]+>/', '', $url);file_put_contents('chamber.html', $url);	// create instance$cssToInlineStyles = new CSSToInlineStyles ( file_get_contents('chamber.html'), file_get_contents('style.css') );//Removes IDs and Classes$cssToInlineStyles->setCleanup(false);// grab the processed HTML$processedHTML = $cssToInlineStyles->convert();str_replace('Home', '', $processedHTML);//Removes links and script tags that emails don't supporthtml2txt("1. <><script< >>alert('hey <br> html2txt <scr<>ipt>');</scr<>ipt>")."<br>";html2txt("2. before <scr<>ipt>document.write('html2txt <scr<>ipt>');</script> after ")."<br>";strip_tags("3. <><script< >>alert('hey <br> strip_tags <scr<>ipt>');</scr<>ipt> ")."<br>";strip_tags("4. before <scr<>ipt>document.write('strip_tags <scr<>ipt>');</script> after")."<br>";function html2txt($text){$search = array('@<>@',  '@<script[^>]*?>.*?</script>@siU',  // Strip out javascript 			   '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly			   '@<embed[^>]*?>.*?</embed>@siU',    // embed			   '@<object[^>]*?>.*?</object>@siU',    // object	    '@<iframe[^>]*?>.*?</iframe>@siU',    // iframe	   			   '@<![\s\S]*?--[ \t\n\r]*>@',	    // Strip multi-line comments including CDATA			  			   '@</?[^>]*>*@'	 // html tags);while($text != strip_tags($text)) { $text = preg_replace($search, '', $text); }return $text;}//Replacing$cut = '<div class="sys_top_menu">';$endcut = '<div class="sys_bc_wrapper" style="width:998px;">';$start = strpos($cut, $cut);$finish = strpos($endcut, $endcut);$length = ($start - $finish);substr_replace($cut,'',$start, $length);substr_replace($endcut,'',$finish, $length);  //Convert character encoding to UTF-8mb_convert_encoding($processedHTML, "utf-8", "utf-8");//Displays Finished Result in Browserecho $processedHTML;//Outputs finished result to filefile_put_contents('finished.html', $processedHTML);?>

Link to comment
Share on other sites

The class has a setCss method you can use to set the new CSS and process the HTML again. $cssToInlineStyles->setHTML($html);$cssToInlineStyles->setCSS($new_css);$html = $cssToInlineStyles->convert();
Hey thanks alot, you really helped me out, i honestly appreciate it. :)Now i'm going to sort out this encoding mess. Check back later i'll post a link of the finished product.Just Incase you want see my current code:
<?phpini_set('max_execution_time', 700);// requirerequire_once 'process.php';//Captures URL and Outputs it to a file that will be used for the conversion$url = file_get_contents('http://test2.chamberhome.com/viewPage.php?ID=Newsletter_1');//Stripping ahead$url = str_replace('</a>', '', $url);$url = preg_replace('/<a[^>]+href[^>]+>/', '', $url);$url = preg_replace('#<link [^>]*>#i', '', $url);/* Nullified for causing unstable page results$url = preg_replace ('#<script [^>]*>#i', '', $url);*/file_put_contents('chamber.html', $url);                // create instance$cssToInlineStyles = new CSSToInlineStyles ( file_get_contents('chamber.html'), file_get_contents('http://test2.chamberhome.com/templates/base/css/common.css') );//Activate for single CSS usage (All the CSS in this file have been combined into one named 'style.css'/*$cssToInlineStyles = new CSSToInlineStyles ( file_get_contents('chamber.html'), file_get_contents('style.css') );*///Multiple CSS usage$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/general.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/anchor.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/forms_adv.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/login_form.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/top_menu.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/BxCustomProfileMenu.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/templates/base/css/login_form.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/listings/templates/base/css/unit.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/groups/templates/base/css/unit.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/videos/templates/base/css/search.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/sites/templates/base/css/main.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/poll/templates/base/css/main.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/news/templates/base/css/view.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/articles/templates/base/css/view.css') );$processedHTML = $cssToInlineStyles->convert();$cssToInlineStyles->setHTML( file_get_contents('chamber.html') );$cssToInlineStyles->setCSS( file_get_contents('http://test2.chamberhome.com/modules/boonex/quotes/templates/base/css/unit.css') );$processedHTML = $cssToInlineStyles->convert();//Removes IDs and Classes$cssToInlineStyles->setCleanup(false);// grab the processed HTML$processedHTML = $cssToInlineStyles->convert();//Replacing/*$cut = '<div class="sys_top_menu">';$endcut = '<div class="sys_bc_wrapper" style="width:998px;">';$start = strpos($cut, $cut);$finish = strpos($endcut, $endcut);$length = ($start - $finish);substr_replace($cut,'',$start, $length);substr_replace($endcut,'',$finish, $length);*/            //Convert character encoding to UTF-8//Please note that utf8_encode only converts a string encoded in ISO-8859-1 to UTF-8. A more appropriate name for it would be "iso88591_to_utf8". If your text is not encoded in  ISO-8859-1, you do not need this function. If your text is already in UTF-8, you do not need this function. In fact, applying this function to text that is not encoded in ISO-8859-1 will most likely simply garble that text./*Alternative Function 1:*/ mb_convert_encoding($processedHTML, "utf-8", "utf-8");/*Alternative Function 2:*//*iconv_set_encoding("internal_encoding", "");iconv_set_encoding("output_encoding", "UTF-8");*///Displays Finished Result in Browserecho $processedHTML;//Outputs finished result to filefile_put_contents('finished.html', $processedHTML);?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...