i got an error
Fatal error: Call to undefined function array_replace_recursive()
because my php-version isn't high enough. So i search for solution or alternative for run array_replace_recursive()
to my current PHP version.
I use the Codeigniter Controller.
Here my code i hope it helps.
<?php
function paginator($options = array() ) {
$keepLive = '';
$sort = (!is_null($this->input->get('sort', true)) ? $this->input->get('sort', true) : '');
$order = (!is_null($this->input->get('order', true)) ? $this->input->get('order', true) : '');
$rows = (!is_null($this->input->get('rows', true)) ? $this->input->get('rows', true) : '');
$search = (!is_null($this->input->get('search', true)) ? $this->input->get('search', true) : '');
$appends = array();
if($sort!='') $keepLive .='&sort='.$sort;
if($order!='') $keepLive .='&order='.$order;
if($rows!='') $keepLive .='&rows='.$rows;
if($search!='') $keepLive .='&search='.$search;
// here's my alternatives of array_replace_recursive().
// starts here...
$options = array();
$options1= array(
'base_url' => site_url( $this->module ).'?'.$keepLive,
'total_rows' => 0 ,
'per_page' => $this->per_page
);
foreach($options1 as $key => $val) {
$options[$key] = $val;
}
$toptions = $options;
//end's here...
/*
// so here's the array_replace_recursive() that i need to replace for alternatives.
$toptions = array_replace_recursive( array(
'base_url' => site_url( $this->module ).'?'.$keepLive,
'total_rows' => 0 ,
'per_page' => $this->per_page,
), $options );
$this->pagination->initialize( $toptions );
*/
$this->pagination->initialize( $toptions );
return $this->pagination->create_links();
}
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…