0

Here is my code:

include('simple_html_dom.php');
$page = file_get_html($_REQUEST['url']);
$page = $page->find('table[class=cf-table-style sorted]',0)->find('tbody',0);
echo ($page);

echo $page is suppose to print HTML but it prints a Array, which means find('tbody',0) is returning array. It shouldn't do like that i think

Where is error in my code.

Wasim A.
  • 9,660
  • 22
  • 90
  • 120

4 Answers4

0

I believe the find function returns array no matter what. Just echo the first element: echo($page[0]);

Smok
  • 246
  • 1
  • 7
  • i don't think so, find('tbody') will return Array but find('tbody',0) will return first element of array – Wasim A. Sep 04 '12 at 12:46
0

You need to extract it using foreach and then echo e.g

foreach($page as pg){
echo pg;
}

try this it may work.

Basha Man
  • 27
  • 5
0
$page = $page->find('table[class=cf-table-style sorted]',0)->find('tbody',0)->innertext;

EDIT 1

innertext returns HTML! Try it in this way:

$chunk = $page->find('table[class=cf-table-style sorted] tbody',0)->innertext;

echo $chunk;
Igor Parra
  • 10,214
  • 10
  • 69
  • 101
0

Try this:

$page = $page->find('table[class=cf-table-style sorted]',0)->find('tbody',0)->plaintext;
print_r($page);
Vinay
  • 2,564
  • 4
  • 26
  • 35