Welcome Guest, Not a member yet? Register   Sign In
Adding Dynamic Data To Views
#2

(This post was last modified: 01-18-2017, 09:02 PM by enlivenapp. Edit Reason: int, not init and commas in arrays... who knew? )

You're just overwriting the first array


There's a couple ways to solve it...

either:

PHP Code:
// First Array
$data = array(
 
  'title' => 'Welcome to CodeIgniter',
 
  'islogged' => $this->user_model->is_logged(),
 
  'username' => $this->user_model->getusername(),
 
  'post_user_id' => $this->user_model->getuserid(),
 
  'post_title' => $post_data['subject'],
 
  'post_message' => $this->parsedown->text($post_data['message']),
 
  'post_id' => $post_data['post_id'],
 
  'post_div_id' => $div_id,
 
  'post_votes' => $post_data['votes']
); 

or something like

PHP Code:
// First Array
$data['array1'] = array(
 
  'title' => 'Welcome to CodeIgniter',
 
  'islogged' => $this->user_model->is_logged(),
 
  'username' => $this->user_model->getusername()
);

// Second Array
$data['array2'] = array(
 
  'post_user_id' => $this->user_model->getuserid(),
 
  'post_title' => $post_data['subject'],
 
  'post_message' => $this->parsedown->text($post_data['message']),
 
  'post_id' => $post_data['post_id'],
 
  'post_div_id' => $div_id,
 
  'post_votes' => $post_data['votes']
); 

or...

PHP Code:
// First Array
$array1 = array(
 
  'title' => 'Welcome to CodeIgniter',
 
  'islogged' => $this->user_model->is_logged(),
 
  'username' => $this->user_model->getusername()
);

// Second Array
$array2 = array(
 
  'post_user_id' => $this->user_model->getuserid(),
 
  'post_title' => $post_data['subject'],
 
  'post_message' => $this->parsedown->text($post_data['message']),
 
  'post_id' => $post_data['post_id'],
 
  'post_div_id' => $div_id,
 
  'post_votes' => $post_data['votes']
);

// then array_merge()... 

Anytime you already have a variable (whether it's an array, string, int, etc) if you define it again, the first 'version' of it is overwritten.
Reply


Messages In This Thread
Adding Dynamic Data To Views - by wolfgang1983 - 01-18-2017, 08:30 PM
RE: Adding Dynamic Data To Views - by enlivenapp - 01-18-2017, 08:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB