Jump to content

Search the Community

Showing results for tags 'array lookup'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. 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! :-)
×
×
  • 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.