I have string like
$a='<tr height="19" style="height:14.25pt">';
using preg_replace
how do i make this to <tr>
$cat = preg_replace('<tr*>', "<tr> ", $a);
How to do this
Using preg_replace <tr *> to <tr>
Page 1 of 13 Replies - 208 Views - Last Post: 20 January 2013 - 01:33 AM
Replies To: Using preg_replace <tr *> to <tr>
#2
Re: Using preg_replace <tr *> to <tr>
Posted 19 January 2013 - 11:08 AM
#3
Re: Using preg_replace <tr *> to <tr>
Posted 19 January 2013 - 08:55 PM
Dear andrewsw
Thanks
Really really appreciate this
Your solution
works like magic !!
with this I could take care of <tr> part
and convert following table
to
using simple commands (as per your guidance
$cat = preg_replace('/<tr.*>/', "<tr> ", $data);
$cat1 = preg_replace('/<table.*>/', "<table> ", $cat);
I tried
$cat2 = preg_replace('/<td.*>/', "<td> ", $cat1);
but this removed all data between td
How do i remove
string
from
in short
convert (using preg_replace)
to
Thanks
Really really appreciate this
Your solution
$cat = preg_replace('/<tr.*>/', "<tr> ", $a);
works like magic !!
with this I could take care of <tr> part
and convert following table
<table border="0" cellpadding="0" cellspacing="0" width="664" style="border-collapse: collapse;width:498pt"> <colgroup><col width="36" style="width:27pt"> <col width="47" style="width:35pt"> <col width="285" style="width:214pt"> <col width="272" style="width:204pt"> <col width="24" style="width:18pt"> </colgroup> <tbody> <tr height="19" style="height:14.25pt"> <td height="19" align="right" width="36" style="height:14.25pt;width:27pt">1004</td> <td width="47" style="width:35pt">QUES</td> <td colspan="2" width="557" style="width:418pt">The first 5 terms of a sequence are -18, -12, -6, 0, 6. If this an AP find 10th term:</td> <td width="24" style="width:18pt">Q</td> </tr> <tr height="21" style="height:15.75pt"> <td height="21" style="height:15.75pt"></td> <td>Given:</td> <td colspan="2">For a sequence, t<sub>1</sub> = -18, t<sub>2</sub> = -12, t<sub>3</sub> = -6, t<sub>4 </sub>= 0, t<sub>5</sub> = 6</td> <td>AS1</td> </tr> </table>
to
using simple commands (as per your guidance
$cat = preg_replace('/<tr.*>/', "<tr> ", $data);
$cat1 = preg_replace('/<table.*>/', "<table> ", $cat);
<table> <tbody> <tr> <td height="19" align="right" width="36" style="height:14.25pt;width:27pt">1004</td> <td width="47" style="width:35pt">QUES</td> <td colspan="2" width="557" style="width:418pt">The first 5 terms of a sequence are -18, -12, -6, 0, 6. If this an AP find 10th term:</td> <td width="24" style="width:18pt">Q</td> </tr> <tr> <td height="21" style="height:15.75pt"></td> <td>Given:</td> <td colspan="2">For a sequence, t<sub>1</sub> = -18, t<sub>2</sub> = -12, t<sub>3</sub> = -6, t<sub>4 </sub>= 0, t<sub>5</sub> = 6</td> <td>AS1</td> </tr> </tbody> </table>
I tried
$cat2 = preg_replace('/<td.*>/', "<td> ", $cat1);
but this removed all data between td
How do i remove
string
width="24" style="width:18pt"
from
<td width="24" style="width:18pt">Q</td>
in short
convert (using preg_replace)
<td width="24" style="width:18pt">Q</td>
to
<td >Q</td>
#4
Re: Using preg_replace <tr *> to <tr>
Posted 20 January 2013 - 01:33 AM
Dear All
I can get clean tables
using following
Thanks
I can get clean tables
using following
$str1 = preg_replace('/height.*?>/', '> ', $data);
echo "<br><br>str1 after replace".htmlentities($str1);
$str1 = preg_replace('/width.*?>/', '> ', $str1);
echo "<br><br>str1 after replac width e".htmlentities($str1);
Thanks
This post has been edited by Dormilich: 20 January 2013 - 03:34 AM
Reason for edit:: please use [CODE] [/CODE] tags when posting code
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|