I have a url string with some text appended on the end which I'm trying to remove: www.domain.com/dns/domain_approve.html?DOMAIN_NAME=anotherdomain.com&id_code=6317e2548dbb4876518de052671f77e7.If for some reason the above link does not work, please go to: Code (markup): I am trying to remove ".If for some reason the above link does not work, please go to:", but for some reason none of the methods I tried work. I've tried str_replace, substr and explode by period and removing the relevant segment but nothing works. Using substr has strange behaviour in that it only removes characters from the URL part of the string even if I specify it to start from the end! Spent a couple of hours on this already and it's doing my head in. Is there a bug in php 5 that I should be aware of?
I can't see why this woulnd't work: $str="www.domain.com/dns/domain_approve.html?DOMAIN_NAME=anotherdomain.com&id_code=6317e2548dbb4876518de052671f77e7.If for some reason the above link does not work, please go to:"; $newStr=substr($str, 0, strpos($str, ".If for")); print($newStr); PHP: EDIT: Tested, it does work. -Jason
Thanks, that works fine I made a mistake in making the wrong assumptions about the order of strings in an array.