Is it possible to define the following data sructure in PHP?
typedef struct
{
int maxrank;
float rankrat[maxpop];
int rankno[maxpop];
individual ind[maxpop],
*ind_ptr;
}population ;
population pop;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t define a data structure other than a
classin PHP, so you can always do that. It would look a little something like this:Looking a bit more at the data structure, you’d also want an
Individualclass, which would be referenced from$population->ind_ptrand$population->ind[]. Just remember, PHP is loosely typed, so your$ind_ptrcan just as well become anarray,stringor whatever else instantly. A quick way around this would be with a type-hinted setter method (and subsequent getter) like this:Alternatively, use an array to define it if it’s only in one location.