simple html code here.
<table> <tr><th>Name</th><th>Price</th><th>Country</th></tr> <tr><td><a href="bbb/111">Apple</a></td><td>500</td><td>America</td></tr> <tr><td><a href="bbb/222">Samsung</a></td><td>400</td><td>Korea</td></tr> <tr><td><a href="bbb/333">Nokia</a></td><td>300</td><td>Finland</td></tr> <tr><td><a href="bbb/444">HTC</a></td><td>200</td><td>Taiwan</td></tr> <tr><td><a href="bbb/555">Blackberry</a></td><td>100</td><td>America</td></tr> </table>
What I want to do is break the name of the company and its price. like this.
Apple 500 / Samsung 400 / Nokia 300 / HTC 200 / Blackberry 100
So, I am using the php dom parser. I know that there are many php parser plugins, but people say it is better to use the original php parser. so i have code like this.
$source_n = file_get_contents($html); $dom = new DOMDocument(); @$dom->loadHTML($source_n); $stacks = $dom->getElementsByTagName('table')->item(0)->textContent; echo $stacks;
many string values โโwill be shown .... like this.
Name Price Country Apple 500 America Samsung 400 Korea ......
I think it is not useful to code, if I code as above, I should use the explode () function, and the code will be messier than now.
How can I break more elegantly? is there a simple link?
source share