Hi,

I am using cURL to grab the contents of a webpage which contains a table. I am trying to make an array out of the table contents, with the column headings as the array keys. Unfortunately the first row of the table, before the headers, has pagination which is messing it all up. The row in question is as follows:

<tr class="DGListPager" align="center">

		<td colspan="6"><b>Page: </b><span>1</span>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl01&#39;,&#39;&#39;)">2</a>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl02&#39;,&#39;&#39;)">3</a>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl03&#39;,&#39;&#39;)">4</a>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl04&#39;,&#39;&#39;)">5</a>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl05&#39;,&#39;&#39;)">6</a>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl06&#39;,&#39;&#39;)">7</a>&nbsp;<a href="javascript:__doPostBack(&#39;ctl00$oCPH1$dgHistory$ctl01$ctl07&#39;,&#39;&#39;)">8</a></td>

	</tr>

I have tried using preg_replace and preg_filter to simply get rid of the extra row, but I haven't had any luck. I am afraid that my regex skill is sub-par. My best attempt is below:

preg_replace('/<tr class="DGListPager" align="center">(.*?)<\/tr>/', '', $output)

If anyone could point me in the right direction here, ti would be a great help. Thanks

After searching around some more, I found the solution. The expression needed the s modifier since there are new lines. So, the final preg_replace looked like:

preg_replace('/<tr class="DGListPager"(.*)\/tr>/iUs', '', $output)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.