Hello all,
I have been struggeling to fix a preg_replace issue i have, and i wonder if someone here might be able to help please?
I am trying to strip the final / off my URL when i feed the URL into a search form i have. Everything else works perfectly, it's just this final / on the end of my URL which is ruining things for me. I'm not sure how to strip it, any advice greatly appreciated.
I tried putting in $drop = strrchr($last, ' ');
but this doesnt change anything. I have no idea where i should put it, or if it is correct, i have just been hacking away cluelessly at this code for days and cant resolve it.
Thanks in advance for any help whatsoever - even if it is to tell me that this is not possible.
Here is the part of my code:
<?php
$search_term = substr($SERVER['REQUEST_URI'],1);
$search_term = urldecode(stripslashes($search_term));
$find = array ("'.html'", "'.+/'", "'[-/]'") ;
$replace = " " ;
$search_term = trim(preg_replace ( $find , $replace , $search_term ));
$search_term_q = preg_replace('/ /', '%20', $search_term);
$full_search_url = $search_url . $search_term_q;
?>
<p>Searching for <a href="<?php echo $full_search_url; ?>"><?php echo $search_term; ?></a></p>