i'm getting the following error in my code while converting to pdf
there's no inline block statement included and width is defined for every table header still issue is persistent
<?php
//print_invoice.php
if(isset($_GET["pdf"]) && isset($_GET["id"]))
{
require_once 'pdf.php';
include('connection2.php');
$output = '';
$statement = $connect->prepare("
SELECT * FROM POrder
WHERE order_id = :order_id
LIMIT 1
");
$statement->execute(
array(
':order_id' => $_GET["id"]
)
);
$result = $statement->fetchAll();
foreach($result as $row)
{
$output .= '
<table width="100%" border="1" cellpadding="5" cellspacing="0">
<tr>
<td colspan="2" align="center" style="font-size:18px"><b>Invoice</b></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" cellpadding="5">
<tr>
<td width="65%">
To,<br />
<b>Vendors Name</b><br />
Name : '.$row["vendorname"].'<br />
Description : '.$row["description"].'<br />
</td>
<td width="35%">
Reverse Charge<br />
Invoice No. : '.$row["order_no"].'<br />
Invoice Date : '.$row["order_date"].'<br />
</td>
</tr>
</table>
<br />
<table width="100%" border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Sr No.</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Actual Amt.</th>
<th colspan="2">GST (%)</th>
<th rowspan="2">Total</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Rate</th>
<th>Amt.</th>
</tr>';
$statement = $connect->prepare(
"SELECT * FROM POrder_item
WHERE order_id = :order_id"
);
$statement->execute(
array(
':order_id' => $_GET["id"]
)
);
$item_result = $statement->fetchAll();
$count = 0;
foreach($item_result as $sub_row)
{
$count++;
$output .= '
<tr>
<td>'.$count.'</td>
<td>'.$sub_row["item_name"].'</td>
<td>'.$sub_row["item_quantity"].'</td>
<td>'.$sub_row["item_price"].'</td>
<td>'.$sub_row["item_price_bt"].'</td>
<td>'.$sub_row["item_gst"].'</td>
<td>'.$sub_row["item_price_at"].'</td>
<td>'.$sub_row["final_amount"].'</td>
</tr>
';
}
$output .= '
<tr>
<td align="right" colspan="11"><b>Total</b></td>
<td align="right"><b>'.$row["total_after_tax"].'</b></td>
</tr>
<tr>
<td colspan="11"><b>Total Amt. Before Tax :</b></td>
<td align="right">'.$row["total_before_tax"].'</td>
</tr>
<tr>
<td colspan="11">Add : GST :</td>
<td align="right">'.$row["gst"].'</td>
</tr>
<td colspan="11"><b>Total Tax Amt. :</b></td>
<td align="right">'.$row["order_total_tax"].'</td>
</tr>
<tr>
<td colspan="11"><b>Total Amt. After Tax :</b></td>
<td align="right">'.$row["total_after_tax"].'</td>
</tr>
';
$output .= '
</table>
</td>
</tr>
</table>
;
}
$pdf = new Pdf();
$file_name = 'Invoice-'.$row["order_no"].'.pdf';
$pdf->loadHtml($output);
$pdf->render();
$pdf->stream($file_name, array("Attachment" => false));
}
?>
// pdf.php
<?php
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
class Pdf extends Dompdf{
public function __construct() {
parent::__construct();
}
}
?>
i expect to get a pdf but instead i get this error
Fatal error: Uncaught exception 'Dompdf\Exception' with message
'Min/max width is undefined for table rows' in
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/TableRow.php:72
Stack trace: #0
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(903):
Dompdf\FrameReflower\TableRow->get_min_max_width() #1
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/AbstractFrameReflower.php(268):
Dompdf\FrameDecorator\AbstractFrameDecorator->get_min_max_width() #2
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(903):
Dompdf\FrameReflower\AbstractFrameReflower->get_min_max_width() #3
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/AbstractFrameReflower.php(268):
Dompdf\FrameDecorator\AbstractFrameDecorator->get_min_max_width() #4
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(903):
Dompdf\FrameReflower\AbstractFrameReflower->get_min_max_width in
/Applications/XAMPP/xamppfiles/htdocs/NTPC/dompdf/src/FrameReflower/TableRow.php
on line 72
It seems that including dompdf like you do is no longer supported, see issue 1153. The guy who's asking gets exactly the same error messages as you do.
I'd recommend to follow the dompdf installation manual and install it with composer (as it is imo thyoue most hassle-free way in the long term). I've also found something on installing composer on XAMPP, but I can't really help with this since I don't know XAMPP. As a fallback you could download a pre-configured package (described some lines below).
And also cheack the quick start tutorial to see if dompdf genereally works instead of using your own code first, because some of it might be deprecated.
Hope this helps, good luck!
Do not apply display property to your table (not in inline styles or external styles).
Found from web:
In this case, the fix ended up being pretty simple, it didn’t like the inline style display:block; that I had added to the table.
Upon a little more testing, I found that it would allow for display:inline; or display:inline-block;.
This makes sense as a table has natively the property display:table; and I think block is probably not really valid (although works fine in browsers, is a neat trick to apply to td elements to create a responsive table, and didn’t generate any warnings during validation.
The solution that worked for me was to downgrade dompdf to 1.0.0
Am not saying it's the best solution but as for now with it was not depending on so many other packages but as it comes with phenx/php-svg-lib and phenx/php-font-lib those were also downgraded.
And also the downside of this is that it was installed in the main packages in composer.json
Note: This will upgrade, downgrade and remove packages currently locked to specific versions of the dompdf/dompdf:1.0.0
The command I used is composer require dompdf/dompdf:1.0.0 -w
For me #Ghazni Ali had the right cause.
Adding any type of display to a table made this error occur.
I was trying to get my elements properly spaced and inline.
What I found was I had to add width to my table and then add additional widths to the td inside of the table.
Below is trying to get a 20% and 80% split.
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 20% !important; border: 1px solid black;">
<p >Left Test</p>
</td>
<td style="width: 80% !important; border: 1px solid black;">
<p >Right Test</p>
</td>
</tr>
</tbody>
</table>
I tried similar methods with using a div tag but it wouldn't appear correct.
The first example is with the table and the bottom two are with div tags.
Related
Here is a code snippet I used to generate PDF when I used mPDF, version of the mPDF is v8.0.
Updated: 30/03/2022, added the settings of mPDF and the stylesheet I used. Found out the "overflow:hidden" in CSS settings triggered the problem.
But a question is, if I do not set the "overflow:hidden" on tables and sometimes when the text inside of the table is pretty long, and font-size will become smaller to make the table fit in a page.
$config = [
'mode' => 'c',
'format' => "A4",
'default_font' => 'arial',
'orientation' => "P",
];
$htmlContent = '<html>
<head>
<style>
#page {
margin-left: 12.7mm;
margin-right: 12.7mm;
margin-top: 20mm;
margin-bottom: 20mm;
margin-header: 5mm;
margin-footer: 5mm; /* <any of the usual CSS values for margins> */
marks: none;
}
table{
width:100%;
overflow:hidden;
}
</style>
</head>
<body>
<div class="page_holder">
<p>25/03/2022</p>
<p>Dear Dr Jayden,</p>
<p>Thank you for agreeing to undertake respirable crystalline silica health monitoring for the following worker.</p>
<table class="wp-block-advgb-table advgb-table-frontend is-style-padding ">
<tbody>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Jayden
</td>
</tr>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff"><strong>Date of Birth</strong></td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">31/12/1989
</td>
</tr>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff"><strong>Description of tasks this worker will complete with engineered stone
fabrication</strong></td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Final Task
</td>
</tr>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff"><strong>History working with engineered stone</strong></td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">History
</td>
</tr>
</tbody>
</table>
<p><strong>If yes, please list previous work history with engineered stone:</strong></p>
<table class="wp-block-advgb-table advgb-table-frontend is-style-padding " style="table-layout: fixed">
<tbody>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Workers Name</td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Jayden
</td>
</tr>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Date of Birth</td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">31/12/1989
</td>
</tr>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Description of tasks this worker will complete with engineered stone
fabrication</td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">Final Task
</td>
</tr>
<tr>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff"><strong>History working with engineered stone</strong></td>
<td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
data-border-color="#ffffff">History
</td>
</tr>
</tbody>
</table>
<p>I confirm that the minimum health monitoring required has been identified in the attached document; WHSQ Health
monitoring standard - crystalline silica. Upon completion of the health monitoring could you please provide a report
for this worker that at a minimum contains the information outlined below.<br>Within the assessment, my business
requires a level of health monitoring that includes:</p>
<ul>
<li>Demographic, medical and occupational history</li>
<li>Records of personal exposure</li>
<li>Standardised respiratory questionnaire</li>
<li>Standardised respiratory function test, including FEV1, FVC, FEV1/FVC - it is strongly recommended this testing
be undertaken by an accredited respiratory function laboratory and include testing of diffusing capacity.
</li>
<li>Chest X-ray full-size PA view - it is strongly recommended an ILO X-ray be undertaken to allow for reading by a
B-reader.
</li>
</ul>
<p>Please include a confirmation in your report that all requirements of the standard have been met.</p>
</div>
</body>
</html>';
$mpdf = new \Mpdf\Mpdf($config);
$mpdf->WriteHTML($htmlContent);
$mpdf->Output();
Don't know what happens on unexpected bold text after the second table.
I have a bunch of attempt editing the html. I could replicate the problem that when I put piece of bold text between two tables. Could anyone help with if the bold text exists between two tables and keep the normal text after the second table?
I'm trying to get multiple href's from a table like this
<table class="table table-bordered table-hover">
<thead>
<tr>
<th class="text-center">No</th>
<th>TITLE</th>
<th>DESCRIPTION</th>
<th class="text-center"><span class="glyphicon glyphicon-download-alt"></span></th>
</tr>
</thead>
<tbody>
<tr data-key="11e44c4ebff985d08ca5313231363233">
<td class="text-center" style="width: 50px;">181</td>
<td style="width:auto; white-space: normal;">Link 1</td>
<td style="width:auto; white-space: normal;">Lorem ipsum dolor 1</td>
<td class="text-center" style="width: 50px;"><img src="https://example.com/img/pdf.png" width="15" height="20" alt="myImage"></td>
</tr>
<tr data-key="11e44c4e4222d630bdd2313231323532">
<td class="text-center" style="width: 50px;">180</td>
<td style="width:auto; white-space: normal;">Link 2</td>
<td style="width:auto; white-space: normal;">Lorem ipsum dolor 2</td>
<td class="text-center" style="width: 50px;"><img src="https://example.com/img/pdf.png" width="15" height="20" alt="myImage"></td>
</tr>
</tbody>
</table>
i try PHP DOM like this
<?php
$html = file_get_contents('data2.html');
$htmlDom = new DOMDocument;
$htmlDom->preserveWhiteSpace = false;
$htmlDom->loadHTML($html);
$tables = $htmlDom->getElementsByTagName('table');
$rows = $tables->item(0)->getElementsByTagName('tr');
foreach ($rows as $row)
{
$cols = $row->getElementsByTagName('td');
echo #$cols->item(0)->nodeValue.'<br />';
echo #$cols->item(1)->nodeValue.'<br />';
echo trim($cols->item(1)->getElementsByTagName('a')->item(0)->getAttribute('href')).'<br />';
echo #$cols->item(2)->nodeValue.'<br />';
echo trim($cols->item(3)->getElementsByTagName('a')->item(0)->getAttribute('href')).'<br />';
}
?>
I get this error
Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on null
getAttribute causes the error
Could someone help me out here please thanks
Your $rows are results of "all the <tr> within <table>". It not only caught the <tr> in the table body, it also caught that in your table head, which has no <td> in it. Hence when reading that row, $cols->item(0) and $cols->item(1) both got you NULL.
You should take the hint when your code didn't find ->nodeValue attribute in the items (hence you added the # sign to suppress the warning).
Try to change this:
$rows = $tables->item(0)->getElementsByTagName('tr');
into this:
$rows = $tables
->item(0)->getElementsByTagName('tbody')
->item(0)->getElementsByTagName('tr');
Now it is searching the <tr> within your <tbody> and should fix your issue with this particular HTML.
To have a more robust code, you should have checked the variables before acting on them. A type check or count check would be good.
As the previous access to the $cols array all have # to suppress the errors, this is the first one that complains.
A simple fix would be to just skip the rest of the code if no <td> elements are found (such as the header row)...
foreach ($rows as $row)
{
$cols = $row->getElementsByTagName('td');
if ( count($cols) == 0 ) {
continue;
}
You could alternatively use XPath and only select <tr> tags which contain <td> tags.
I am trying to export HTML to Excel format using php headers, but CSS styling is not applying on elements (while export to excel file), I also try to implement Bootstrap Classes, but no luck
Note: while applying bootstrap classes, I included the bootstrap.css in my html
Is there any way available to apply CSS?
Headers using
header('Content-type: application/excel');
header("Content-Disposition: attachment; filename=\"$filename\"");
Sample HTML elements
<table width="100%" border="1" class="table table-striped table-bordered">
<thead>
<tr>
<td colspan="9" style="font-weight: bold; font-size: 16px; text-align: center;"><h2>Push Notification </h2></td>
</tr>
<tr><td colspan="9"></td></tr>
</thead>
<tbody>
<tr class="heading">
<th colspan="2" ></th>
<th style="width:2% !important">S.no</th>
<th style="width:10% !important">Date</th>
<th style="width:10% !important">App</th>
<th style="width:20%">Category</th>
<th colspan="2" style="width:50%">Message</th>
</tr>
#if($push_notifications->count() > 0)
<?php $counter = 1; ?>
#foreach($push_notifications as $notification)
<tr #if(($counter %2) ==1) bcolor="#c9c9c9" #endif>
<td colspan="2"></td>
<td style="width:2% !important">{!!$counter!!}</td>
<td style="width:10% !important">{!!$notification->date!!}</td>
<td style="width:10% !important">{!!$notification->notificationAppType->name!!}</td>
<td style="width:20%">{!!$notification->notificationCategory->name!!}</td>
<td colspan="2" style="width:50%">{!!htmlentities($notification->message, ENT_QUOTES)!!}</td>
</tr>
<?php $counter++; ?>
#endforeach
#else
<tr>
<td colspan="9">No record available</td>
</tr>
#endif
</tbody>
</table>
Short answer is no, you can't apply css to excel.
You can, however, apply some formatting to the text of excel files, but the amount of formatting is limited by the library you use to generate the excel file and to what formatting the excel itself permits.
I am trying to use tcpdf library to generate pdf. I have a php file which contains variables like name,company name etc. But for displaying the products I am passing the array to php. Now I want to display each element of array in a table row for that I have to write the php code but somehow I am having problem mixing PHP code with html code.Here is the part whihch contains the problem
$html .= '<br><br>
<table border="1" cellpadding="5">
<tr>
<td colspan="3">Invoice # {invoice_ref_id}</td>
</tr>
<tr>
<td><b>Product</b></td>
<td><b>Quantity</b></td>
<td align="right"><b>Amount (Rs.)</b></td>
</tr>'.
foreach($item as products): .' //This part contains error
<tr>
<td>'echo products['item']'</td>
<td>'echo products['quantity']'</td>
<td align="right">75</td>
</tr>
<tr>
<td colspan="3" align="right"><b>Total: 375</b></td>
</tr>'
endforeach;
'</table>';
$html .= '<br><br>Some more text can come here...';
Instead of concatenating your HTML in a string that you will then need to echo, I would go to something like this :
<br><br>
<table border="1" cellpadding="5">
<tr>
<td colspan="3">Invoice # {invoice_ref_id}</td>
</tr>
<tr>
<td><b>Product</b></td>
<td><b>Quantity</b></td>
<td align="right"><b>Amount (Rs.)</b></td>
</tr>
<?php foreach($item as products){ ?>
<tr>
<td><?php echo products['item'] ?></td>
<td><?php echo products['quantity'] ?></td>
<td align="right">75</td>
</tr>
<tr>
<td colspan="3" align="right"><b>Total: 375</b></td>
</tr>
<?php> } //ending the foreach ?>
</table>
<br><br>Some more text can come here...
Notice how even here HTML code is still correctly highlighted? It will probably be the same in your editor of choice. I find it much more readable, and you even avoid possible character escaping issues.
NOTE : I didn't fix your HTML, but there are several bad practices in it regarding semantics or even use of obsolete/deprecated tags. Here are a few:
Don't use anything changing layout in your HTML, this is what CSS are for. For example, don't use border or cellpadding attributes on your table, use table {border: 1px solid #ccc;} (you can of course change color, that's an example) and table td {padding: 5px;} instead.
Semantic best practices also imply not using <br> tag. Better define top or bottom margins to put some space between elements. (I must admit that's probably the only example where I value ease over semantic and sometimes use it myself though)
<b> tag should be use only in very specific cases, cfr this article. In this specific case you can achieve the same effect (bold text) by using font-weight: bold on the desired cells, either by giving them a specific CSS class, either by targetting them with a CSS selector like for example : tr td:nth-child(3) {font-weight: bold;}}
similarily, don't use align attribute, same thing, target the desired cell and use CSS property text-align: right; instead.
You can't continue the html with a concatenation straight after the foreach. You have to do $html .= again.
This
</tr>'.
foreach($item as products): .' //This part contains error
<tr>
should be this
</tr>';
foreach($item as products): $html .= ' //This part contains error
<tr>
The same goes at the end of the foreach:
</tr>';
endforeach;
$html .= '</table>';
You are doing it wrong way. This should work -
$html .= '<br><br>
<table border="1" cellpadding="5">
<tr>
<td colspan="3">Invoice # {invoice_ref_id}</td>
</tr>
<tr>
<td><b>Product</b></td>
<td><b>Quantity</b></td>
<td align="right"><b>Amount (Rs.)</b></td>
</tr>';
foreach($item as products) { //This part contains error
$html .= '<tr>
<td>'. products['item']. '</td>
<td>'. products['quantity']. '</td>
<td align="right">75</td>
........ ';
}
$html .= '</table>';
$html .= '<br><br>Some more text can come here...';
thie right way of doing something like this
$html .= '<br><br>
<table border="1" cellpadding="5">
<tr>
<td colspan="3">Invoice # {invoice_ref_id}</td>
</tr>
<tr>
<td><b>Product</b></td>
<td><b>Quantity</b></td>
<td align="right"><b>Amount (Rs.)</b></td>
</tr>';
foreach($item as products):
$html .=' //This part contains error
<tr>
<td>'echo products['item']'</td>
<td>'echo products['quantity']'</td>
<td align="right">75</td>
</tr>
<tr>
<td colspan="3" align="right"><b>Total: 375</b></td>
</tr>';
endforeach;
$html .= '</table>';
$html .= '<br><br>Some more text can come here...';
I'm using Simple HTML Dom and it's working very well on most of my Data. However, on is being a pain as the markup isn't valid. Is there any other way to do this in PHP.
I've got this result from a page I'm trying to extract the price from:
<taconite><replacecontent select="#basketcontents"><![CDATA[
<table id="sellingb" cellpadding="10px" cellspacing="15" width="600" border="0">
<thead>
<tr class="title">
<th width="47" scope="col" align="center">Book</th>
<th width="213" scope="col" align="left">Title</th>
<th width="139" scope="col" align="left">ISBN/Barcode</th>
<th width="63" scope="col" align="left">Value</th>
<th width="29" scope="col"> </th>
</tr>
</thead>
<tbody>
<tr class="trrow">
<td class="tdbook" align="center" valign="middle" ><img src="http://ecx.images-amazon.com/images/I/61JEp-wF3zL._SL75_.jpg" /><input name="offers_row_img[0]" type="hidden" value="http://ecx.images-amazon.com/images/I/61JEp-wF3zL._SL75_.jpg" /></td>
<td class="tdtitle">The Last Of Us (PS3) [Video Games]<input name="offers_row_title[0]" type="hidden" value="The Last Of Us (PS3) [Video Games]" /></td>
<td class="tdisbn">0711719274551<input name="offers_row_isbn[0]" type="hidden" value="0711719274551" /></td>
<td class="tdval">£15.00<input name="offers_row_price[0]" type="hidden" value="15.00" /></td>
<td class="tdremove"><input type="button" onclick="removeitem(0);" value="Reject Offer" /></td>
</tr>
</tbody>
</table>]]></replacecontent><eval><![CDATA[jQuery('#isbn').val('');]]></eval><replacecontent select="#price"><![CDATA[£15.00<br /><input type="button" class="bask-sb" id="acceptoffer" onclick="confirm('By clicking OK you are accepting the offer of £15.00 for your 1 item(s).'); acceptoffer();"/>]]></replacecontent></taconite>
However, there seems to be a problem. Simple HTML Dom only works on valid markup and this isn't valid. What is dthe best way I can extract the £15.00 from this result.
Thanks. It is much appreciated.
Only use valid markup, unless the markup is use by another resource.
One alternative could be to use strpos()/substr() for example:
$price = substr($input,strpos($h, "$")); // or euro symbol whatever you need
$price = substr($x, 0, strpos($x, "<"));
I assume your input is set to the variable $input.
This will only work well if you can be fairly sure that the next character after the price will be a < and that there will only be one price instance. If there will be more than one price instances you'll have to adjust it to get the right one(s).