May 29, 200818 yr Page: HERE Referring to the weather stats box on top of the banner, I'd like to make sure that wind speed (m/s) is always on the line below wind speed (kts). The m/s wind speed sometimes begins right next to the kts speed. The php code for this area of the weather stats is as follows: if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts (".sprintf(KTStoMS($data_clientraw[$clientraw_cpt]))." m/s)";} I've tried inserting nl2br as below. This does not work, 'nl2br' is displayed in the rendered html page... if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts nl2br(".sprintf(KTStoMS($data_clientraw[$clientraw_cpt]))." m/s)";}
May 29, 200818 yr What does $data_clientraw[$clientraw_cpt] usually contain? try this: if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts " . nl2br(sprintf("(" . KTStoMS($data_clientraw[$clientraw_cpt])))." m/s)";} Sorry if its garbage, half asleep
May 29, 200818 yr Or if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts "\n" (".sprintf(KTStoMS($data_clientraw[$clientraw_cpt]))." m/s)";} Pat
May 29, 200818 yr How about a simple <br /> echo ? or am I missing something. Where would I place that in the code? And I thought that <br /> tags don't work in php?
May 29, 200818 yr if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts<br />(".sprintf(KTStoMS($data_clientraw[$clientraw_cpt]))." m/s)";}
May 29, 200818 yr Or if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts "\n" (".sprintf(KTStoMS($data_clientraw[$clientraw_cpt]))." m/s)";} Pat Results in the following error : Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/rusclub/public_html/weather/final_clientraw_parser.php on line 35 Parse error: syntax error, unexpected T_STRING in /home/rusclub/public_html/weather/final_clientraw_parser.php on line 35
May 29, 200818 yr That wont work anyway, line breaks are ignored by browsers. try the <br /> version and let us know how you get on
May 29, 200818 yr Is this the correct code to use (note <br />)? if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. " kts <br />(".sprintf(KTStoMS($data_clientraw[$clientraw_cpt]))." m/s)";} if (eregi('Compass', $types_clientraw[$clientraw_cpt])) I didn't realise you could use html tags such as <br /> within php code (hence this post )...
May 29, 200818 yr sure, $data_clientraw[$clientraw_cpt] ends up being a simple string. Which can then be echo'd. The only only thing you might have trouble with is your using " instead of ' if it throws up an error, swap your " for '. like this. if (eregi('Knots', $types_clientraw[$clientraw_cpt])) {$data_clientraw[$clientraw_cpt] = $data_clientraw[$clientraw_cpt]. ' kts <br />('.sprintf(KTStoMS($data_clientraw[$clientraw_cpt])).' m/s)';} for an explanation that makes sense... http://www.weberdev.com/get_example-3750.html
May 29, 200818 yr <br /> on its own worked. The only problem I have is that it also created a line break on the Gusts stats... Will need to sort that bit out. Thanks for all the help guys .
Create an account or sign in to comment