I am tasked with pulling data from HTML where I need to get arrays of data for each set of p tags in the HTML. Here is a sample bit of HTML.
<p class="ft01" style="margin: 0; padding: 0; font-size: 16px; font-family: Times; color: #000000; position: absolute; top: 103px; left: 63px; white-space: nowrap;">Title </p>
<p class="ft01" style="margin: 0; padding: 0; font-size: 16px; font-family: Times; color: #000000; position: absolute; top: 103px; left: 349px; white-space: nowrap;">1234 </p>
<p class="ft01" style="margin: 0; padding: 0; font-size: 16px; font-family: Times; color: #000000; position: absolute; top: 103px; left: 461px; white-space: nowrap;">$30 </p>
<p class="ft01" style="margin: 0; padding: 0; font-size: 16px; font-family: Times; color: #000000; position: absolute; top: 103px; left: 563px; white-space: nowrap;">$10,000,000 </p>
<p class="ft01" style="margin: 0; padding: 0; font-size: 16px; font-family: Times; color: #000000; position: absolute; top: 103px; left: 777px; white-space: nowrap;">3,000,000 </p>
This HTML will repeat a number of times with the "Title" and "1234" labels staying the same, and then switching to different labels at a certain point. The "top" and "left" values will constantly change throughout the HTML. I have the ability to loop through existing "Title" and "1234" labels to match against that portion of things.
$title_label = 'Title';
$number_label = '1234';
preg_match_all('%\d{2}px; white-space: nowrap;">$title_label </p>%', $html_content, $array_match);
$array_cost_name = $array_match[1];
$array_return_name = $array_match[2];
$array_number_name = $array_match[3];
I would then need the 3 arrays to contain the last 3 label fields. In the case of the sample HTML provided I would want "$30", "$10,000,000" and "3,000,000" to be the first values of each array.
I am not sure how to go about writing a regular expression to handle this situation. Can anyone help?