473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

modifying link tags.

ok what i need to do is modify all the link tags in a string from <a
href="blah.html"to <a href="clicktrough.php?uri=blah.htmlbut the
problem is some of the tags have class so <a class="llama"
href="blah.html"but i dont want to change all of the tags that
contain "href" because that would mess with the css. the code i am
using right now is
<?
$file = file_get_contents('http://kingcow.com/');
$llama = preg_split('/<a(.)*href=\"/', $file, -1, PREG_SPLIT_NO_EMPTY);
echo join("",$llama);
?>
this works but the problem is it removes the <a......>.

any help is grately appricated.

//elliott

Jul 22 '06 #1
1 1034
el***********@gmail.com wrote:
ok what i need to do is modify all the link tags in a string from <a
href="blah.html"to <a href="clicktrough.php?uri=blah.htmlbut the
problem is some of the tags have class so <a class="llama"
href="blah.html"but i dont want to change all of the tags that
contain "href" because that would mess with the css.
Would something as follows do what you want?

preg_replace('/(?<=href=")([^"]+)/', 'clicktrough.php?uri=$1', $source);
JW
Jul 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Japcuh | last post by:
How do you write self modifying code in Java? Japcuh (Just Another Perl C Unix Hacker) http://www.catb.org/~esr/faq/hacker-howto.htm#what_is ..0. ...0 000
6
by: sentinel | last post by:
Hi, I’m trying to modify a DHTML editor that parses a style-sheet via PHP and instead of modifying the tags via execCommand(), find a way of writing inline styles by way of adding <span style=>...
2
by: Travis | last post by:
Hi everyone, I'm using the System.Drawing.Imaging.Bitmap to retrieve and modify the metadata tags (user comments, keywords etc) of JPEGS. I was wondering if changing these tags in any way...
4
by: moondaddy | last post by:
I've build a basepage that will be used for all the pages in my website. I created a propery in the base page called Title like this: Private baseTitle As HtmlGenericControl Protected Property...
17
by: The Numerator | last post by:
I know a lot about HTML, but all this time I don't know what the <LINK> tags in the head do. There are those that call a stylesheet, favicon, etc. But what about those that state the contents of...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
5
by: Bubba | last post by:
I need to use an inline css tag for a few links that will not behave like the a:link and a:hover attributes in my stylesheet. I want to add a special link color with underline and a mouseover...
2
by: John | last post by:
Hi there, I've just been reading "ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps" by K. Scott Allen (http://odetocode.com/Articles/450.aspx) and discovered how rebasing works with URL's in...
1
mikek12004
by: mikek12004 | last post by:
I have an XML file representing categories like this <?xml version='1.0' encoding='utf-8' ?> <bank> <img> <src>img/GF0813-1_thumb.jpg</src> <title>classicΙ</title> <caption>Click...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.