+ 1
Create array of type Person
I've created a class called Person and would like to know if it is possible to create an array of that class type. I am able to do it in Java so I was just curious.
6 Answers
+ 1
I've tried $people = array() and then $person = new Person(...) to add it into the array.. Thanks!
+ 6
Person [ ] persons = new Person [5];
for(int i=0; i<persons.length; i++){
persons [i] = new Person();
// or you can take user input
}
+ 5
Sorry for not noticing Php tag! My code was for Java. It's good that your problem is already solved :)
+ 4
For sure it's possible except person is an abstract class.
+ 1
Oh no, its okay :) thanks for the help though!
0
Oh okay, I'm new to OOP PHP. I've created two classes (both in the same file). How would I go about creating the array?