Say I have a multi-dimensional array like this,
$details = array(
'fruit' => array(
'path' => '/tmp/fruit',
'headers' => array(
'size',
'weight',
'colour')),
'car' => array(
'path' => '/tmp/car',
'headers' => array(
'model',
'fuel',
'colour')),
'animal' => array(
'path' => '/tmp/animal',
'headers' => array(
'species',
'sex',
'locale'));
Why won't this work? Lets say the url is example.url/web/page/fruit
$uriPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$base = basename($uriPath);
if(in_array($base, $details)) {
echo($details[$base]['path']);
}
Is there a better way?
$basein this case?