Unstoppable Domains

How to use Php to strip a particular link?

Spaceship Spaceship
Watch

newsiness

VIP Member
Impact
49
Hi,

Let's say i have string like this

$str= '<a href="blah blah">Namepros Rock!</a>TEXT TEXT<a href="blah blah">Hello World</a>';

I want to strip out the word Hello World and output something like this
$str= '<a href="blah blah">Namepros Rock!</a>TEXT TEXT';

Please advice!

Thanks!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
There has to be some way to identify what you want to remove - and that's important. Would it always have the same text or href? Or maybe it will always be the second link? Perhaps it is a set number of characters every time (so you use substr)?
 
0
•••
PHP:
<?php
$str= '<a href="blah blah">Namepros Rock!</a>TEXT TEXT<a href="blah blah">Hello World</a>';

$str=preg_replace('#(.)<a.*$#', '\1', $str);

echo $str."\n";
?>
 
0
•••
More ideas

Search the w3school hoping it may help you
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer

We're social

Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back