0

I would create an expression or a code that adds the "tr" tag between the table and td, noting that the table has attributes...

<table border="0" bgcolor="#FFFFFF"><td bgcolor=...
<table width="780"><td align=...

I would have to stay that way

<table border="0" bgcolor="#FFFFFF"><tr><td bgcolor=...
<table width="780"><tr><td align=...

There are several combinations of attributes in the table, have to cover all

Can someone help me?

Sorry for the spelling errors, I used Google translator

1 Answers1

0

This maybe

$re = "/(<table.*>)(<td.*)/"; 
$str = "<table border=\"0\" bgcolor=\"#FFFFFF\"><td bgcolor=...\n<table width=\"780\"><td align=..."; 
$subst = "$1<tr>$2"; 

$result = preg_replace($re, $subst, $str);

here is the demo... https://regex101.com/r/oO9hX0/1

tanaydin
  • 5,171
  • 28
  • 45