I am just starting with Simple PHP HTML DOM PARSER so, what is the way to replace text only of any fetched content. Suppose i have fetched some content from a website with full HTML codes, but while applying PHP code like $html = str_replace(".", "DOT", $html); it cause a error. Because in this case it replace all . with DOT so that all links are broken, but what i want is just to replace . to DOT in texts but all code should be untouched.
Assuming, The fetched data is something like this
<a href="http://example.com">Example.com</a>
The Output should be like this
<a href="http://example.com">ExampleDOTcom</a>
how to do like this? I'm a beginner so please describe more ... sorry for the damn question :)

If you use a DOM parser, then you should loop through all nodes, replacing only the dot in the value texts.

so what i should do if i need to replace something else .. may you have any example ..

Replace what else?

okay, please show me a example with . if possible.

Show the code you have so far.

something like this:

    <?php
    include("dom.php");
    $html = file_get_html("http://www.ssssssssss.com/");
    $result = $html->find('ol', 0);
    $nav_bar = $html->find('div[id=navbar]', 0);
    $result = str_replace($nav_bar, '', $result);
    echo $result;
    ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.