Author Topic: PHP Scripting assistance Formating a large text variuable output  (Read 806 times)

0 Members and 1 Guest are viewing this topic.

Offline Arthurhh

  • Senior Contributor
  • ****
  • Posts: 266
  • IT Fixer
    • Tokoroa Weather Live
PHP Scripting assistance Formating a large text variuable output
« on: December 27, 2010, 07:25:04 PM »
I have a variable say $info

It contains a reasonable amout of data which I wish to output in a page while making it wrap at say 600px wide (or x charactures wide)  

Example text
Code: [Select]
NORTHERLY GALES POSSIBLE ABOUT THE NORTHERN NORTH ISLAND UNTIL LATE AFTERNOON
A cold front lying over the northern South Island at 9am will sweep quickly across the North Island today.
A strong northwesterly flow ahead of the front may bring a period of north to northweterly gales to the northern part of the North Island today.  The strongest winds are expected around the middle of the day.
At this stage it looks unlikely wind gusts will reach severe gale (>110km/hr) in these areas, however MetService will maintain a Watch until the front passes through.
Winds are easing over the northern South Island and the Watch for strong northerly winds in Nelson and Buller is now lifted.
This Watch will be reviewed by 6pm Tuesday 28 December 2010
It is wrapping here but doesnt on my page tried a DIV tried a Table any other ideas

See problem here http://tokoroaweatherlive.net/wxadv-1SevereWeatherWatch.php if there is a watch issued

Okay I am getting better actually have sort of solved this, but interested in alternative/better ideas.
Used
Code: [Select]
$string = 'This string needs to be wrapped';
$string = wordwrap($string, 350, "<br />");

echo '<div>' . $string . '</div>';
« Last Edit: December 27, 2010, 07:37:56 PM by Arthurhh »