I need to do quite a lot of string manipuation in PHP for an application that we are setting up. I am familiar with PHP, but I've not used the string functions much, and after pouring over some resources this afternoon, I decided that the experts would provide a quicker way for me to get up to speed.
The app is pulling entire web pages from other domains into a string and then delivering them inline as part of a locally hosted page. Here is what I need to be able to do:
1)For images, stylesheet references, .js files, et all, I need to take all the non-explicit links (there is a proper term for this which escapes me..) and make them explicit. e.g.
2) manipulate the string so that links like <a href="/fred/index.php> click me </a>
becomes: <a href="http://www.myserver.com/page.php?linkpath=http://www.theirserver.com/fred/index.php
> click me </a>
(the links get handled by the local app, and then the corrosponding remote page is loaded inline as part of a local page.)
3) I also need to accomodate in both of these scenarios for page relative links that will need to be converted to the full path, including the domain.
of course the use of whitespace in the first two examples will vary as HTML allows ( can be src= " or src = " or src =" , et all)
4) Finally, (and I'll gladly put this up as a seperate question with points if I'm asking too much here for my 500...) I need to trace the user's click path as they move from page to page. There requests will all be handled by the same PHP page on the local site (page.php in point 2 above), with the target page appering after the ?. I'm assuming that I cannot store that data in an array, as the array would be re-dimensioned each time that page.php is loaded, so my preference would be to write the data to an xml document so that I can manipulate it with other tools for reporting purposes. I would like to be able to transform the xml document into html for display on the site as well.