|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
dynamic replacement of words in an external txt
Hi all, this forum has been great use to me in picking up help and code for my various work projects..
currently i'm working on some code that allows me to populate the links in a flat html file with an extra url variable e.g http://www.blahblah.com?oldvariable=8&newvar=12 becomes http://www.blahblah.com?oldvariable=8&newvar=20 there are usualyl about 30 of these links in a text file each of which require a different value for the chosen url variable. i was doing quite well - i can read the file in and remove all the old values so that i'm just left with http://www.blahblah.com?oldvariable=8&newvar= but to replace all these with different numbers i used the following code.. which as i'm sure you'll rapidly realise does something rather distasteful: PHP Code:
yes - as i discovered today the replace function only returns the string from the start parameter of the function. can anybody point me in the right direction - all i need is to keep the rest of the string before the point where the replace is made.. then it should work fine... Thanks for any help |
|
#2
|
|||
|
|||
|
Look into Regular Expresions. http://www.4guysfromrolla.com/webte...pressions.shtml
That should get you started |
|
#3
|
|||
|
|||
|
yeah - i'd tried regular expressions previosly - came into difficulty when there was more than once occurence on each line.. but not to worry - i came up with a solution to the above problem...
PHP Code:
cheers for the suggestion tho... hope anyone who comes up against a similar problem find this helpful.. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > dynamic replacement of words in an external txt |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|