Jump to content

[SOLVED] array help


Recommended Posts

I have this code:

 

<?php
    $url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $find = false;
    
    $aryCarriers = array('cat', 'dog');
    
    foreach($aryCarriers as $carrier) {
        if(strpos($url, $carrier)) {
        	$find = "http://localhost/web/pcc/" . $carrier;
        } else {
        	$find = "ERROR";
        }
    }

echo $find;

?>

 

If dog is the last string in the array and is in the url (http://localhost/web/pcc/dog/page.php) everything works fine! But if dog is anywhere else in the array it does not work. Any suggestions on this?

Link to comment
https://forums.phpfreaks.com/topic/159927-solved-array-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.