Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm a fresh grad, and I just started workingin real world projects. I'm basically using PHP most of the time. I just figured out that most of the solutions I came out with for most of the problems, is involving using an array in somehow. What Am I doing wrong here? How could I unlearn this and always think of something else? Or is it the fault of the language?

share|improve this question
    
What kind of problems are you looking at? –  XQYZ May 9 '12 at 0:10
4  
Minor note: sometimes excessive use of arrays (or collections, in other languages) can be a symptom of object denial. Specifically if the content of the array is "structured" in that the first element has a specific meaning and the second element has a different specific meaning, then someone's probably building an "object" disguised as an array. If, however, the elements in the array are all of the same type (i.e. they are interpreted in the same way), then it's a "true" array. That's not specific to PHP, but can happen in pretty much all languages. –  Joachim Sauer May 9 '12 at 5:41

2 Answers 2

Most programming is going to involve manipulating a collection of some sort, of which the array is the most basic type. Other languages use Lists, Vectors and Dictionaries\Associative arrays a lot as well but PHP utilizes the same syntax for both associate arrays and numeric arrays.
Do you want to use other data types? Sure, when you have a demonstrated performance problem or need a particular structure like a stack or queue. Using a lot of various search structures and various sort and search algorithms for large data sets is often unnecessary due to databases. This is of course provided you understand how to structure and index your tables properly. If it helps, a few Fortran programmers used to think about various data structures as types of arrays.

share|improve this answer

I've been using PHP for, I think, around 6 or 7 years now. I find myself using arrays quite a bit. With built in sorting and looping functions, they are easy to work with and help manipulate data the way I need to.

Where you say "...or is it the fault of the language?" It's only a fault if it causes some problem, prevents you from solving a problem, or uses more resources than you might otherwise use, so I'd say there's likely no fault to be had.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.