I wrote a function to strip parameters from urls, the function looks like this
function remove_it($c_link){
$regex = array();
$award = array();
$regex[] = '/[\?&](?<name>sa)=(?<value>[^&=]+)/';
$regex[] = '/[\?&](?<name>ei)=(?<value>[^&=]+)/';
$regex[] = '/[\?&](?<name>ved)=(?<value>[^&=]+)/';
$regex[] = '/[\?&](?<name>usg)=(?<value>[^&=]+)/';
foreach($regex as $remove){
$c_link = preg_replace($remove,'',$c_link);
}
return $c_link;
}
When I use a testurl like this
$test = 'http://forum.gofeminin.de/forum/dietetique/__f2955_dietetique-Diatpillen.html&sa=U&ei=8doOUa6HOsfKtAaDpICIBQ&ved=0CB0QFjAA&usg=AFQjCNEcFS48QvteNkSNcszXv5RG6VUe2g';
It’s woking perfect. Now I wanted to use it in my code. So I called to function with my data and it doesn’t affect the string. I used print_r to see if the string looks strange, but it’s just 1:1 like in $test
$TEST-> http://forum.gofeminin.de/forum/dietetique/__f2955_dietetique-Diatpillen.html&sa=U&ei=C9wOUZuvCoeQtQavpoHoDg&ved=0CB0QFjAA&usg=AFQjCNHkRBKRpZXZX7idJ6YmSG0AIxtOdw
print_r-> http://forum.gofeminin.de/forum/dietetique/__f2955_dietetique-Diatpillen.html&sa=U&ei=C9wOUZuvCoeQtQavpoHoDg&ved=0CB0QFjAA&usg=AFQjCNHkRBKRpZXZX7idJ6YmSG0AIxtOdw
As I used all debugging methods that I know of, I don’t really know where I should start searching… any pointers ?
I made antoher testrun, and saved all data in an array, later on I wanted to stript the parameter for 1 url. Here the testcode:
echo '<pre>';
print_r($test).'</br>';
echo remove_it($test[0]);
echo '</pre>';
break;
the output was like :
Array
(
[0] => http://forum.gofeminin.de/forum/dietetique/__f2955_dietetique-Diatpillen.html&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CDUQFjAA&usg=AFQjCNGgMS-nHM2JY_PkIt7C_RT2dr9bUw
[1] => http://www.fitforfun.de/abnehmen/gesund-essen/diaetpillen/diaetpillen-appetitzuegler_aid_2100.html&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CEEQFjAB&usg=AFQjCNG60KJy3wLR8DnLm9gKQEn-uR6l3w
[2] => http://www.stern.de/ernaehrung/uebergewicht-abnehmen/diaetpillen-check-welche-mittel-machen-duenn-das-abc-der-schlankmacher-615772.html&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CEYQFjAC&usg=AFQjCNGLzi5UMG4g5INDkeBdMpENgY4gHg
[3] => http://getslim.de/diaetpillen-im-test&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CEoQFjAD&usg=AFQjCNEcZnpSlVVxLgskK9DfhBF9AHGC2w
[4] => http://www.br.de/fernsehen/bayerisches-fernsehen/sendungen/gesundheit/themenuebersicht/medizin/schlankheitspillen-diaet-tabletten100.html&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CFQQFjAE&usg=AFQjCNHujKjdfNsOkarYf6MwHCPODcISjw
[5] => http://www.diaetpillenvergleich.de/beste-diatpillen/&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CFoQFjAF&usg=AFQjCNFBgbYjgutHJfp-eQztXTsKYk7rTw
[6] => http://www.diaetpillen-online.de/&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CF4QFjAG&usg=AFQjCNF083onO0rkMuQjY0tEIhhdSM4Igg
[7] => http://diaet.erdbeerlounge.de/Diaetpillen/&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CGIQFjAH&usg=AFQjCNFhNr-gsFxK1-vfjhnC1A5qQi1ZjQ
[8] => http://diaet.erdbeerlounge.de/abnehmen-forum/Diaetpillen-_t2698848s1&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CGcQFjAI&usg=AFQjCNHhHY3zUnJtwF6-HV-DbsxaVUFxsg
[9] => http://www.gutefrage.net/tag/diaetpillen/1&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CG0QFjAJ&usg=AFQjCNHPYODXZA1Sa2rs6ItnUWTOYkJj3w
)
http://forum.gofeminin.de/forum/dietetique/__f2955_dietetique-Diatpillen.html&sa=U&ei=LOIOUaqQGITntQbmmIHYBQ&ved=0CDUQFjAA&usg=AFQjCNGgMS-nHM2JY_PkIt7C_RT2dr9bUw
I made the test array and it works for me. It seems that your code is fine and something else is wrong.
Try wrapping the function input in double quotes.