"Cut" String

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I created a simple blog on a web site. On homepage I am displaying the
last posts.

For each post I show the Post Title, the Post Updated Date and the
beginning of the Post Body.

When the user clicks Title it will be redirected to a new page showing
the full Post Body ....

The Post Body might contain HTML code ... the content is defined in
the variable PostBody.

How can I get the beginning part of PostBody??

- I need to be sure that I don't break HTML code;

- I would like to define an approximate length.

Is this the way how is it done?

Thank You,
Miguel
 
Hello,

I created a simple blog on a web site. On homepage I am displaying the
last posts.

For each post I show the Post Title, the Post Updated Date and the
beginning of the Post Body.

When the user clicks Title it will be redirected to a new page showing
the full Post Body ....

The Post Body might contain HTML code ... the content is defined in
the variable PostBody.

How can I get the beginning part of PostBody??

     - I need to be sure that I don't break HTML code;

     - I would like to define an approximate length.

Is this the way how is it done?

Thank You,
Miguel

Please, anyone?

Thanks,
Miguel
 
After serious thinking shapper wrote :
Hello,

I created a simple blog on a web site. On homepage I am displaying the
last posts.

For each post I show the Post Title, the Post Updated Date and the
beginning of the Post Body.

When the user clicks Title it will be redirected to a new page showing
the full Post Body ....

The Post Body might contain HTML code ... the content is defined in
the variable PostBody.

How can I get the beginning part of PostBody??

- I need to be sure that I don't break HTML code;

- I would like to define an approximate length.

Is this the way how is it done?

Thank You,
Miguel

You could first filter out any html codes, that is anything between a
"<" and the next ">".
Then you will have the plain text.
If this is less than your required length, then you are done.
Else you should inspect around that position: you might be in a
&agrave; or something like that. Find out if you are between a "&" and
";". If so you can adjust to either before the "&" or after the ";".

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top