Jump to content

Convert ASP to PHP (replace VBCrlf)


ramone_johnny

Recommended Posts

vbCrlf is a Carriage-Return--Line-Feed pair. In PHP, it is "\r\n".

 

Or you could add a define in the PHP code:

define('vbCrlf', "\r\n");
Note: The double-quotes are required here because those escape sequences are not interpreted in single-quotes.

Thank you.

 

It seems I still have this annoying issue.

 

My text is being displayed like this........

 

I have a room available in my 2 bed flat in Ashgrove.

The flat is in
a quiet block of six units and is an older style flat so

nice and
roomy.

The room is unfurnished, but I can source a bed if you

need.

There is great storage in the room with built in

cupboards, and the
room is large enough to fit a queen bed, chest of draws

and
bedside table.

Sorry, I gave an incomplete answer. shlumph is correct, depending on which way that asp statement is. If you are replacing CRLF with <BR> (for HTML display) it would be the first one.

 

echo str_replace("\r\n", "<BR>", $property_description);
Or you can look at the nl2br function, which doesn't actually replace them, it just inserts the HTML <BR> before the CRLF (which is fine for HTML).

 

echo nl2br($property_description);
What I was getting at with the define, was something like this

define('vbCrlf', "\r\n");

echo str_replace(vbCrlf, '<BR>', $property_description);

Thanks again. That makes sense. (Sorry my background is ASP)

 

I tried the nl2br method and got the same result.

 

You can see the issue I'm faced with here (this is the asp version) in the description.

 

http://www.housemates.com.au/share_ads/share_open.asp?share_ID=7243

 

It's really annoying.

What, exactly, are you trying to accomplish? It seems you are replacing linebreaks in the source and converting them to <br> tags - which causes a line break in the HTML content. But, it seems that is creating some undesired output. Looking at this sample output:

I have a room available in my 2 bed flat in Ashgrove.
The flat is in
a quiet block of six units and is an older style flat so
nice and
roomy.

The room is unfurnished, but I can source a bed if you
need.

There is great storage in the room with built in
cupboards, and the
room is large enough to fit a queen bed, chest of draws
and
bedside table.

It seems that the source content has linebreaks that you don't want included in the output. We really need to see a sample of the actual source content and how you want it to be displayed to provide a good answer. Based on the above, I *think* the answer might to convert double linebreaks in the source to an HTML <BR> tag and leave the rest alone.

I'm guessing because, last time I checked, double <br>'s don't have a standard height across browsers.  This can be modified with CSS... but I think that's why he did it that way.

 

The style attribute should be quoted.  Better yet, give it a class name like "break", then move the styling into a stylesheet.

I'm guessing because, last time I checked, double <br>'s don't have a standard height across browsers.  This can be modified with CSS... but I think that's why he did it that way.

 

Then the content should be put in a paragraph tag, <P>, and it should be styled with appropriate line height properties. Then the <BR> tag will generate the appropriate height. Using an empty <DIV> tag is very poor form. In fact, that could cause very different display on different browsers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.