php – How to break a line in an XML Feed according to the page width?

Question:

I have a table with 15 items and I need to break the columns when the total size of the items reaches the full width of the table.

Ex.:

What is happening:

|--- WIDTH 300px ---|

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

What I need done:

|--- WIDTH 300px ---|

01 02 03 04 05 06

07 08 09 10 11 12

13 14 15

I have this feed as an example and my current code is this:

<div style="width:300px; max-width:300px">
    <?php
       $a = file_get_contents("http://v2.afilio.com.br/aff/aff_boutique_show_ads.php?boutiqueid=37930-895843&currencypos=0&display_img=1&diplay_name=1&diplay_price=1&thumbsize=80%&truncate_desc=15&numrows=1&numcols=20&colorname=000000&colorprice=E30000&bkcolor=FFFFFF&bordercolor=FFFFFF&self_target=0&");
       echo ($a);
    ?>    
</div>

Also I would like to know, is it possible to use JavaScript instead of PHP?

Answer:

Mathew,

You can actually solve it by simply adding the word-wrap: break-word; style word-wrap: break-word; on your div.

Example, I put 120px to give the result of your example:

<div style="width:120px;word-wrap: break-word; max-width:120px">
    <p>
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
    </p>
</div>
Scroll to Top
AllEscort