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

  • Home
  • SEARCH
  • 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 9231185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:00:37+00:00 2026-06-18T06:00:37+00:00

HTML <table id=’dg’ border=’0′ class=Table> <tr> <td class=’text’>id.</td> <td class=’text’>file</td> <td class=’text’>alt</td> </tr> <tr>

  • 0

HTML

<table id='dg' border='0'  class="Table">
  <tr>
    <td class='text'>id.</td>
    <td class='text'>file</td>
    <td class='text'>alt</td>
  </tr>
  <tr>
    <td class='text'><input name='somename[]' type='hidden' value='1234'>
      1</td>
    <td class='text'><a href='#' onClick="javascript:openPopWindow('../../somefile.jpg');" ><img src='cms_thumb.php?imgsrc=somefile2.jpg' border='0' ></a></td>
    <td class='text'><input type='text' name='title[]' value='Value 1'></td>
  </tr>
  <tr>
    <td class='text'><input name='somename[]2' type='hidden' value='2345'>
      2</td>
    <td class='text'><a href='#' onClick="javascript:openPopWindow('../../somefile2.jpg');" ><img src='thumb.php?imgsrc=somefile2.jpg' border='0' ></a></td>
    <td class='text'><input type='text' name='title[]' value='Value 2'></td>
  </tr>
</table>

OBJECTIVE

Need to get img src filename and get value of the input field which have name=title[]

WHAT I HAVE SO FAR

$dom = new DOMDocument;
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);

foreach ($dom->getElementsByTagName('tr') as $node) { 
    $img = $xpath->query('//img')->item(0); 
    $img = str_replace("\'","",$img->getAttribute('src'));
    $img = str_replace("cms_thumb.php?imgsrc=","",$img);
    echo $img.'<br>';
}

$img contains just first image and not other

  • 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-06-18T06:00:38+00:00Added an answer on June 18, 2026 at 6:00 am

    Try:

    $html = <<<HTML
    <table id='dg' border='0'  class="Table">
      <tr>
        <td class='text'>id.</td>
        <td class='text'>file</td>
        <td class='text'>alt</td>
      </tr>
      <tr>
        <td class='text'><input name='somename[]' type='hidden' value='1234'>
          1</td>
        <td class='text'><a href='#' onClick="javascript:openPopWindow('../../somefile.jpg');" ><img src='cms_thumb.php?imgsrc=somefile2.jpg' border='0' ></a></td>
        <td class='text'><input type='text' name='title[]' value='Value 1'></td>
      </tr>
      <tr>
        <td class='text'><input name='somename[]2' type='hidden' value='2345'>
          2</td>
        <td class='text'><a href='#' onClick="javascript:openPopWindow('../../somefile2.jpg');" ><img src='thumb.php?imgsrc=somefile2.jpg' border='0' ></a></td>
        <td class='text'><input type='text' name='title[]' value='Value 2'></td>
      </tr>
    </table>
    HTML;
    
    
    $doc = new DOMDocument();
    $doc->loadHTML($html);
    
    
    foreach($doc->getElementsByTagName("td") as $td){
        foreach($td->getElementsByTagName("img") as $img){
            $arr_img[] = array(
                "img" => $img->getAttribute("src"),
            );
        }
        foreach($td->getElementsByTagName("input") as $name){
            if ($name->getAttribute("name")==="title[]"){
                $arr_value[] = array(
                    "value" => $name->getAttribute("value")
                );
            }
        }
    }
    
    var_dump($arr_img); // In this array will be img src's
    var_dump($arr_value); // In this array will be values of input elements which name equal to title[]
    

    var_dump Outputs will be =>

    array(2) {
      [0]=>
      array(1) {
        ["img"]=>
        string(34) "cms_thumb.php?imgsrc=somefile2.jpg"
      }
      [1]=>
      array(1) {
        ["img"]=>
        string(30) "thumb.php?imgsrc=somefile2.jpg"
      }
    }
    
    array(2) {
      [0]=>
      array(1) {
        ["value"]=>
        string(7) "Value 1"
      }
      [1]=>
      array(1) {
        ["value"]=>
        string(7) "Value 2"
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this HTML table: <table width=1100 border=1 style=text-align:center; class=invoice> <tr><td>&nbsp;</td><td>&nbsp;</td><td>Amount Due</td><td>Amount Enc.</td></tr> <tr><td>&nbsp;</td><td>&nbsp;</td><td>CAD
I have an html table <table border=0 width=100%> <tr class=headerbg> <th width=5%> No </th>
If I create a HTML table like this: text text text <table border='0'> <TR>
I have the following html table <table id={64ED3A94-5833-4CC7-869F-CCE583B498BE} class=ms-listviewtable width=100% cellspacing=0 cellpadding=1 border=0 xmlns:o=urn:schemas-microsoft-com:office:office
I have an HTML table in my jsp page. This conains text fields and
I have an HTML table that contains some 500 rows. I have an input
I have this html table: <table class=table-all> <tbody> <tr> <td>BISFENOLO</td> <td>Bisfenolo-AF 10/10</td> <td class=right>€
In my HTML table, the width of a column increases, when the text inside
I've got an html table with a number of checkboxes : <table id=webcam-table class=pretty>
I have the following HTML table and want to replace the subtable class =

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.