A
A
Artqookie2010-10-09 11:20:24
PHP
Artqookie, 2010-10-09 11:20:24

Removing some text with PHP

I will make a reservation that I am still a lamer in PHP.

Let's say we have a link:

<a href="#" title="Title">Link</a>

How to delete?

 title="Title"

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mithgol, 2010-10-09
@Mithgol

With qJerry , working with XML in PHP is as easy as  working with jQuery in Javascript with HTML.
Here is the code:

q('<a href="#" title="Title">Link</a>')->removeAttr('title')->dump();
outputs:
<?xml version="1.0"?>
<a href="#">Link</a>

G
Grigory Peretyaka, 2010-10-09
@Peretyaka

Something like this, I haven't tested it, but it should work:

str_replace('<a href="#" title="Title">Link</a>','<a href="#">Link</a>',$Text);

S
skvot, 2010-10-09
@skvot

Install the engine to work with the DOM as described above. There is also an alternative to use JS, but I'm not entirely sure if this is appropriate in your case (JS will work after generating the html code).

K
Kir Shatrov, 2010-10-10
@RazoR_Empire

People, but there is an html parser, it is still used on Habré ... There you can set allowed tags and attributes. What is it called?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question