-2

how to remove onmousedown="return curwt(this, 'http://www.example.com/2009/07/content.html')" using str_replace( ), i know how to use this string but can not understand the way to configure this string to remove onmousedown="all content" in this way.
I have tried in this way: $result = str_replace("onmousedown''", " ", $result);
But it will not work.. any idea?

user1642787
  • 75
  • 1
  • 2
  • 7

2 Answers2

4

I think that you want to use a regular expression

$result = preg_replace('/onmousedown=".*?"/', '', $result);

Or if it can be both apostrophes and quotes:

$result = preg_replace('/onmousedown=("|\').*?\1/', '', $result);
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
0

You can't use str_replace for this, because it can only replace pre-defined strings, no wildcards.

You can use preg_replace for this.

Daniel M
  • 3,369
  • 20
  • 30