在我的serialize()中,我有3个参数。会员ID,firtname和姓氏
a:3:{s:9:"member_id";s:1:"1";s:9:"firstname";s:7:"John";s:8:"lastname";s:12:"Doe";}
正如你所看到的那样只有第一个名字
当前输出
<a href="http://www.example.com/admin/member/profile/?member_id=1">John</a>
它应该是什么
<a href="http://www.example.com/admin/member/profile/?member_id=1">John Doe</a>
问题:如何确保在vsprintf()
中也可以获得姓氏
public function test() {
$this->data['logs'] = array();
$logs = $this->log_model->getlogs();
foreach ($logs as $log) {
$comment = vsprintf('<a href="member_id=%d">%s</a> logged in.', unserialize($log['log_text']));
$find = array(
'member_id'
);
$replace = array(
site_url('admin/member/profile/?member_id')
);
$this->data['logs'][] = array(
'comment' => str_replace($find, $replace, $comment),
'date_added' => date("F jS, Y H:i:s A", $log['log_date'])
);
}
}
答案 0 :(得分:0)
我现在已经解决了%3$s
$comment = vsprintf('<a href="member_id=%d">%s %3$s</a> logged in.', unserialize($log['log_text']));