Hi all
After giving this one hours of thought and tedious trial, I saw myself obliged to join and ask here...
I made this function to look up the price from a $product.
I have an include on pages where I need the prices in the variables like the 3 first ones in the example.
The problem is that my function is only working when I hardcode prices as keys.
I tried all sorts of methods to get access to what's in the vars from within the function, but I'm starting to fear this is not possible and I can't use this way?
OTOH, it doesn't seem like keys have to be numbers, so I hope there is something I'm not getting...
$kofferprijs_Disco = 6.5;
$kofferprijs_Hawaii = 8;
$kofferprijs_Pirates = 7;
function priceLookup($product){
$pricelist = array(
$GLOBALS['kofferprijs_Disco'] => 'DISCOFEEST',
$GLOBALS['kofferprijs_Hawaii'] => 'HAWAI/TROPICAL',
$GLOBALS['kofferprijs_Pirates'] => 'PIRATES',
);
if (in_array($product, $pricelist)) {
$price = array_search( $product, $pricelist );
return $price;
}
}
$productPrice = priceLookup('PIRATES'); // should give me '7'
Tried every variation know to man...
$kofferprijs_Pirates
$$kofferprijs_Pirates
${$kofferprijs_Pirates}
$$GLOBALS['kofferprijs_Pirates']
${$GLOBALS['kofferprijs_Pirates']}
...
Thanks for any help! :-)