Solved

remove format from text

Posted on 2006-11-25
8
331 Views
Last Modified: 2008-02-01
Hello experts ....

i have a PHP site that display news

some times my client copy and paste news from news site ..... so he copy formated test and paste it in the text area in the form i made to him to insert news into Data base

my question is :

1- if he entered formated test into the data base .... can i disply this formated text without formt  ?? coz i take the frist 400 characters from the last new and display it in the home page and i want to display it without format


2- is it possiple to remove format when the Admin press insert button in the insertion form ??



Thanks





FLAASHER
0
Comment
Question by:FLAASHER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:ictinus
ID: 18013628
can you post an example of what you want and don't want?
0
 
LVL 13

Author Comment

by:FLAASHER
ID: 18013643
the user copy this line from another site :

" this is sample text of the admin copy and paste  "




But becuse i provided him with rich text era format when he copy and paste the text into the insertion form the text inserted into the data base as following :
 
this is <span class="style5">sample text </span>of the <strong>admin copy a</strong>nd paste





i diplay this text in the home page and i need to display it without any format ..... i want it just a plain text  .... want to display it like this :


" this is sample text of the admin copy and paste  "





FLAASHER
0
 
LVL 1

Assisted Solution

by:ictinus
ictinus earned 100 total points
ID: 18013661
you can use str_replace so long as certian elements are the same so in this case you would use str_replace to take out the <stong> and <span> tags.  

$string_from_db = "this is <span class="style5">sample text </span>of the <strong>admin copy a</strong>nd paste
"

$replace1 = "<span class="style5">";
$replace2 = "</span>";


$new_string = str_replace(" $replace1 ", " ( leave blank here because you want to replace it with white space ", "$string_from_db");

echo $new_string;

that's an example here is a reference to str_replace .

http://us2.php.net/str_replace

0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 13

Author Comment

by:FLAASHER
ID: 18013667
i want to remove all HTML tags ......  not only <stong> and <span>


<stong> and <span> just fro example




FLAASHER
0
 
LVL 8

Assisted Solution

by:John Kawakami
John Kawakami earned 150 total points
ID: 18013719
$string = preg_replace('/<.+?>/', '', $string);
0
 
LVL 13

Author Comment

by:FLAASHER
ID: 18013736
Dear jk2001
 Many  thanks


can u please explain this line to me ??



FLAASHER
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 18013750
you might also use the function strip_tags for that:
http://php.net/strip_tags

0
 
LVL 13

Author Comment

by:FLAASHER
ID: 18013769
Thanks all


angelIII  provide me with the best answer




FLAASHER
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question