Page 1 of 1
Changing links in html
Posted: Mon Nov 22, 2004 8:09 pm
by nyk
Why won't this command
Code: Select all
$html=preg_replace('/http:\/\/subwww.unibe.ch\//','?c=',$html);
replace the URL with the ?c= ???
Posted: Mon Nov 22, 2004 9:22 pm
by rehfeld
it looks like it should work to me, but maybe im missing it
still, you dont need regex for that, this is faster
Code: Select all
$html = str_replace('http://subwww.unibe.ch/', '?c=', $html);
Posted: Tue Nov 23, 2004 3:54 am
by nyk
this doesn't replace anything. but the string to be replace occurs many times!
Code: Select all
$center=str_replace('href="http://subwww.unibe.ch/','href="?c=',$html);
Posted: Tue Nov 23, 2004 4:17 am
by rehfeld
if not, then you $html variable prob doesnt contain what you think, or your not using the result from str_replace correctly.
do this:
Code: Select all
echo $html;
echo "\n\n---------\n\n";
echo str_replace('http://subwww.unibe.ch/', '?c=', $html);
dont seperate those 3 lines and put other code in between, keep them together exactly as i posted them.
then just view the resulting source and your problem shoudl be obvious
if your still stumped, post the whole code here