2009-09-27, 03:28 PM
I want to set it so that I can check a URL for a certain extension (in specified list) and return results based on whether it appears or not.
I know I have to explode the following (I know that most of the code is wrong, but I'm posting it so that you can get the gist of what I want):
$url = "http://www.test.com";
$old_ext = ".com,.net,.org,.info";
$ext = explode(",", "$old_ext");
$check = stristr("$url","$ext");
if ($check == '$ext') {
echo "Domain has allowed extension.";
}
else {
echo "Domain does not have allowed extension";
}
Regardless, is there an easier way? Could I use a foreach statement instead maybe?
Edit: Wrong forum, please move to General Chat.
I know I have to explode the following (I know that most of the code is wrong, but I'm posting it so that you can get the gist of what I want):
$url = "http://www.test.com";
$old_ext = ".com,.net,.org,.info";
$ext = explode(",", "$old_ext");
$check = stristr("$url","$ext");
if ($check == '$ext') {
echo "Domain has allowed extension.";
}
else {
echo "Domain does not have allowed extension";
}
Regardless, is there an easier way? Could I use a foreach statement instead maybe?
Edit: Wrong forum, please move to General Chat.