FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Need help accessing the key array.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Need help accessing the key array. [message #185448 is a reply to message #185447] Mon, 31 March 2014 14:33 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 3/31/2014 9:26 AM, Kevin Burton wrote:
> On Monday, March 31, 2014 6:35:41 AM UTC-5, Jerry Stuckle wrote:

>>
>>>> A decent idea, but much harder than it needs to be. A simple two
>>>> dimensional array suffices for what he needs. See the other updates in
>>>> this thread.
>>
>>> In order for a 2D array to work you have to change the input array and the input parameters. Right?
>>
>> Nope. Just make the array itself two dimensional. A lot easier than
>> all of your code (and a lot fewer changes, also).
>
> But what if you can't change the input array?
>

What input array? The array is generated in the code, and the indicies
are coming from the user - probably via either $_GET or $_POST values.

He is generating this array in his code to hold the values, and needs to
only index properly into the array to get the result he wants. No
searching or classes needed, i.e. (after proper filtering, of course)

$rate = $rates[$_POST['animal']][$_POST['color']];

Much easier to understand and code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Most secure way to reset a password via email link
Next Topic: Strange but true! Working with interfaces in PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Jun 16 20:13:56 GMT 2024

Total time taken to generate the page: 0.04698 seconds