• 0

Convert HTML Tags to DIV Tags


Question

Hi Guys,

 

I'm looking to convert the following an ACF Table that outputs <tr>. <td>, etc. tags, into div tags, so that it's responsive in my WordPress website.


Can anyone help me?

 

<!--CODE STARTS-->

 <?php $table = get_field( 'table1' ); 
                
 if ( $table ) { 
     echo "<div style=\"text-align:center\">";
     echo '<table>'; 
         if ( $table['header'] ) { 
             echo '<thead><tr>'; 
                 echo ''; 
                     foreach ( $table['header'] as $th ) { 
                         echo '<th>'; 
                             echo $th['c']; 
                         echo '</th>'; 
                     } 
                 echo '</tr>'; 
             echo '</thead>'; 
         } 

         echo '<tbody>'; 
             foreach ( $table['body'] as $tr ) { 
                 echo '<tr>'; 
                     foreach ( $tr as $td ) { 
                         echo '<td>'.$td['c'].'</td>'; 
                     } 
                 echo '</tr>'; 
             } 
         echo '</tbody>'; 
     echo '</table>'; 
 } ?> 
<?php the_field( '' ); ?>

<!--CODE ENDS-->

 

If you could help me out, I would greatly appreciate it. Thanks!

 

This is where it is now at the bottom of the page. I would like to center it too: https://www.schnellindustries.ca/lowell/conveyors/

 

- Lowell

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.