B
B
Bjornie2016-11-20 03:58:56
PHP
Bjornie, 2016-11-20 03:58:56

How to remove text between quotes?

I spent the whole evening trying to solve the problem. The clock is already late at night and I honestly got tired of solving this problem. I tried to use regular expressions, strip_tags, substr, but it's not that.
Initial data:
- simple_html_dom.php
- block of html code, which after parsing has the text from the title attributes of the link ( ). When using the plaintext attribute, I get everything as bare text, including these attributes, and I don't need them in the parsed text. At the same time, the name of the link should naturally be left, deleting only that one. what's in the title. Tell me how to do it? <a href="" title="Some text">Link name</a>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2016-11-20
@xmoonlight

$html = str_get_html('<a href="" title="Some text">Link name</a>');
$e = $html->find("a");
$link = $e->href;
$name = $e->innertext;
simplehtmldom.sourceforge.net/manual.htm

A
Andrzej Wielski, 2016-11-20
@wielski

$string = '<a href="" title="Some text">Link name</a>';
preg_replace('#\"(.*)\"#', $string);
echo $string;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question