I'm learning PHP and working in Codeigniter. I feel that I am typing similar things over again (duplicating work) when I am making data arrays and declaring the variables I need for functions.
Here is an example:
//MAKE ARRAY OF USER ANSWERS TO QUESTIONS
$dropdowndata = array
( 'user_socialhour' => $this->input->post('socialhour'),
'user_socialpm' => $this->input->post('socialpm'),
'user_eventhour' => $this->input->post('eventhour'),
'user_eventpm' => $this->input->post('eventpm');
//DECLARE THE VARIABLES I NEED FOR FUNCTIONS
$user_socialhour = $this->input->post('socialhour');
$user_socialpm = $this->input->post('socialpm');
$user_eventhour = $this->input->post('eventhour');
$user_eventpm = $this->input->post('eventpm');
$calculateddata = array
('user_mornafteve' => $this->mornafteve($user_socialhour, >$user_socialpm), 'user_beforeafter' => $this->beforeafter($user_socialpm, >$user_eventpm, $user_socialhour, $user_eventhour));
I am looking for a way to automate the declaration of all the variables in the dropdowndata array. I am looking for something like, for each key, declare the variables according to the following pattern.
Does this exist?