Page 1 of 1
Remove case sensitivity from this script?
Posted: Tue Sep 18, 2007 3:34 pm
by JAB Creations
This script needs to be made case insensitive. So if someone clicks to get to my site using the string 'Two' it will not currently match.
Code: Select all
<?php
$lostsouls = array( "one", "two", "three");
list($parameter_string) = array_reverse(explode('?', $_SERVER['HTTP_REFERER']));
$parameters = explode('&', $parameter_string);
foreach($parameters as $parameter) {
list($key, $value) = explode('=', $parameter);
$args = explode('+',$value);
foreach($args as $item){
if(in_array($item,$lostsouls)){header("Location: http://www.example.com/");
}
}
}
?>
Posted: Tue Sep 18, 2007 3:51 pm
by feyd
What have you tried?
Posted: Tue Sep 18, 2007 3:53 pm
by JAB Creations
Code: Select all
in_array(trim(mb_strtolower($item)),$lostsouls)
Code: Select all
in_array(trim(strtolower($item)),$lostsouls)
Code: Select all
in_array(strtolower($item),$lostsouls)
Code: Select all
(in_array(strtolower($item),strtolower($lostsouls))
Posted: Tue Sep 18, 2007 4:00 pm
by JAB Creations
This works fine with Lycos but not with Bearshare...
Code: Select all
<?php
$lostsouls = array( "one", "two", "three");
list($parameter_string) = array_reverse(explode('?', $_SERVER['HTTP_REFERER']));
$parameters = explode('&', $parameter_string);
foreach($parameters as $parameter) {
list($key, $value) = explode('=', $parameter);
$args = explode('+',$value);
foreach($args as $item){
$item = urldecode($item);
$i = explode(' ',$item);
foreach($i as $x){
if (in_array(trim(strtolower($item)),$lostsouls)) {
header("Location: http://www.example.com/");
}
}
}
}
?>
Posted: Tue Sep 18, 2007 4:03 pm
by feyd
What are the differences between the two?
Posted: Tue Sep 18, 2007 4:17 pm
by JAB Creations
Thanks for the replies. Got it working and as always here is the final code...
Code: Select all
<?php
$lostsouls = array( "one", "two", "three");
list($parameter_string) = array_reverse(explode('?', $_SERVER['HTTP_REFERER']));
$parameters = explode('&', $parameter_string);
foreach($parameters as $parameter) {
list($key, $value) = explode('=', $parameter);
$args = explode('+',$value);
foreach($args as $item){
$item = urldecode($item);
$i = explode(' ',$item);
foreach($i as $x){
if (in_array(trim(strtolower($x)),$lostsouls)) {
header("Location: http://www.example.com/");
}
}
}
}
?>