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 #185423 is a reply to message #185414] Sun, 30 March 2014 17:14 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 3/29/2014 6:32 PM, Kongthap Thammachat wrote:
> Hi, what I am trying to do is to receive animal variable and color variable from the user, and finally display associated rate for the input animal and input.
>
> I'm looking for any ways rather than looping through the $rates array, is there any possible ways?
>
> Thanks.
>

Please do not top post. It makes the sequence very hard to read.

I agree with Denis and J.O. - they have a much better way of handling
this. But some other comments:

1. Why use 0, 1 and 2? Why not "bear", "tiger" and dog" for the animal,
and "black", "brown" and "white" for the color (as an example)? This
will be much easier to understand. And the HTML, if correctly defined,
can return these as easily as 0,1 and 2.

Additionally - if this is all you will ever have, then what you have may
work fine. The main question I would have is - if you have to change
the rate, add a color, or whatever - how much code are you going to have
to change?

If you ever are going to have something different, my suggestion would
be to start using a database such as MySQL or PostgreSQL now. Using a
database means that all you have to do is update the database for new
items or attributes or a rate change, and the results will be reflected
in all of your pages. The database will also handle the searches for you.

It takes a bit more work up front, but will save in the long run. It
will also be easier to start using a database now then to try to change
your code later.

--
==================
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 Nov 24 21:22:45 GMT 2024

Total time taken to generate the page: 0.05441 seconds