Reply to Re: replace all _self with _blank

Your name:

Reply:


Posted by Marcin Dobrucki on 03/06/06 11:21

bboldi wrote:
> Ok. I know about these functions, the problem is: i need to determine
> if target attribute is alredy defined, if not, i need to insert one, if
> yes, then replace the variable of target attribute i have problen with
> "finding if target att. is defined and inserting one if not" part. any
> idea? thanx in advance.

I hope this is not some homework...

if (preg_match("target", $url)) {
// search and replace
}
else {
// crude but effective, url in form:
// <a href="someplace.html" option="value">link text</a>
$url_array = explode('>', $url);
$new_url = $url_array[0].' target="your_target">'.$url_array[1] . '>';
}

To do a bit more work, search for the position of the first '>', and
then insert a string into the url (eg. with stripos() and
substr_replace()) just before that place.

Of if you really want to put effort in, tokenize the whole url, and
then parse the arguments as you see fit.

/Marcin

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация