When you do a copy and paste even selecting plain from the link you provided here is what you get
- Code: Select all
// new dom object
$dom = new DOMDocument();
//load the html
$html = $dom->loadHTMLFile(data.html);
//discard white space
$dom->preserveWhiteSpace = false;
//the table by its tag name
$tables = $dom->getElementsByTagName('table');
//get all rows from the table
$rows = $tables->item(0)->getElementsByTagName('tr');
// loop over the table rows
foreach ($rows as $row)
// get each column by tag name
$cols = $row->getElementsByTagName('td');
// echo the values
echo $cols->item(0)->nodeValue.'<br />';
echo $cols->item(1)->nodeValue.'<br />';
To find this out do a right click on the page and view the code - I can select the text I want to copy and then right click and view my selection only and that is what is in the code snippet above.
Those would be hidden in most editors but depending on your Save As setting they may well also be saved in to the file you create.
The web developer should have known better than to add those entities when posting php code snippets - it makes html looks nice but the repercussions for other codes are 4 hours of trying to sort out the developers mess.
So when you copy and paste from a web site page make sure that you are only copying only the code that you expect.