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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
Link to comment
Share on other sites

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.

Edited by Psycho
Link to comment
Share on other sites

Aha!

 

I managed to get it sorted out. (using brute force)

 

Thanks to the suggestion made above by psycho.

 

<? echo str_replace("\r\n\r\n", "<div style=font-size:0;height:10px;></div>", $property_description); ?>

Edited by ramone_johnny
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.