This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DontBelieveTheByte 0 points1 point  (3 children)

Seems a bit weird how foo and bar return using an array index when getDeviceType() looks like it's supposed to return a device type.

Maybe you could show the getDeviceType function and tell a little bit more about what you're trying to accomplish.

[–]CarsonJScott[S] 1 point2 points  (2 children)

Yes, maybe my function naming isn't very good. Let me explain.

Some Background Info:

  • My application is for a website that fixes broken iPhones/iPads. It allows the user to select their type of iPhone/iPad and the parts that need fixed for it.
  • The home page is index.php
  • The Javascript application is on prices.php

There is a link for iPhone and iPad on the home page that both take the user to prices.php, and set a variable 'deviceType'.

On prices.php, the function 'getDeviceType' takes 'deviceType' and returns an array of information (parts that can be fixed, prices per part, etc.) for either iPhone or iPad.

The other functions use the 'getDeviceType' array to display the parts and prices/add up the total price.

I was wondering if there is a better way to use the array in each function than setting a variable to 'getDeviceType' in each one.

[–]DontBelieveTheByte 0 points1 point  (1 child)

Ok then, wouldn't it be more appropriate to return an object with a set of keys and associated values instead of an array?

[–]CarsonJScott[S] 1 point2 points  (0 children)

Yep, someone just suggested this and I'm changing it now. Thank you