Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 829967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:57:58+00:00 2026-05-15T03:57:58+00:00

This is mycode <?php /** * @author Joomlacoders * @copyright 2010 */ $url=http://urlchecker.net/html/demo.html; $innerHtml=file_get_contents($url);

  • 0

This is mycode

<?php

/**
 * @author Joomlacoders
 * @copyright 2010
 */
    $url="http://urlchecker.net/html/demo.html";

    $innerHtml=file_get_contents($url);

    //echo $innerHtml;
    preg_match_all("{\<div id='news-id-.*d'\>(.*)\</div\>}",$innerHtml,$matches);

          //<div id='news-id-160346'>            

    var_dump($matches);

?>

I want find all content in div id=’news-id-160346′. Please help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:57:59+00:00Added an answer on May 15, 2026 at 3:57 am

    Use an HTML parser. NOT regular expressions.

    The problem with regular expressions is that they cannot match nested structures. Assuming your regex must match a single <div> and its closing tag, there is no way to correctly match this input:

    <div id="a">
        <div id="b">
            Foo
        </div>
    </div>
    <div id="c">
        Bar
    </div>
    

    Because if your regular expression is greedy, it will match the two uppermost divs, and if it’s ungreedy, it will not match the correct end tag.

    Therefore, you should use an HTML parser. With PHP, DOMDocument::loadHTML or DOMDocument::loadHTMLFile each do a fairly good job. (You may “safely” ignore the warnings it generates: they’re only markup errors, and the generated DOMDocument object should be pretty much okay.)

    Since the PHP getElementById is a pain to get to work, you can use DOMXpath for the same purpose:

    <?php
    
    $url = "http://urlchecker.net/html/demo.html";
    
    $d = new DOMDocument();
    $d->loadHTMLFile($url);
    
    $xpath = new DOMXPath($d);
    $myNews = $xpath->query('//@id="news-id-160346"')->item(0);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code: <? php $content = file_get_contents(http://aux.iconpedia.net/uploads/1337412470.png); $fp = fopen(/test/image.jpg, w); fwrite($fp,
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
For Example if i have my code like this (php): <?php somefunc(1); function somefunc($a)
My code is like this: <?php define(ERROR, SOMETHING WRONG WITH MY DATABASE); ... if
My code is somewhat like this: <?php if($_REQUEST['post']) { $title=$_REQUEST['title']; $body=$_REQUEST['body']; echo $title.$body; }
I need a fix for this. here is just part of my code <?php
I have this code for doing an ajax request to a webservice: var MyCode
I'm using PHP to display the most recent tweet from a user. This is
I have a registration module with PHP validation. This coding shows the error and
I am sending a HTTP request via cURL and I keep getting this 413

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.