I want to make 10 variables with name as answer-1,answer-2,answer-3 and so on. Can i use for loop in such a manner to create variables, if not then how can i do it?
<?php
for(i=1;i<=10;i++){
$answer_+i=new array();
}
?>
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.
Your PHP syntax is all wrong (Yes you missed some
$s and added extranew). You can create them using following syntax. Its called variable variablesBut I suggest you use array for this. Array is more convenient.
Here your
$answer_1will be$answer[1]. Best is to use no explicit indexNow
$answer_1will be$answer[0]. You can loop over it byfor,foreach, can use a lot of array functions.