Welcome Guest, Not a member yet? Register   Sign In
[Solved] How to set 3 arg for vsprintf()
#1

(This post was last modified: 10-27-2017, 09:35 PM by wolfgang1983.)

In my serialize() I have 3 arg. Member id, firstname, and lastname


PHP Code:
a:3:{s:9:"member_id";s:1:"1";s:9:"firstname";s:7:"John";s:8:"lastname";s:12:"Doe";} 


As you can see it only out puts the first name 

Current Output


Code:
<a href="http://www.example.com/admin/member/profile/?member_id=1">John</a>


What it should be 


Code:
<a href="http://www.example.com/admin/member/profile/?member_id=1">John Doe</a>


Question: How can I make sure can get last name as well in vsprintf()


PHP Code:
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'])
        );
    }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

Read the manual.
Reply
#3

Solved now


PHP Code:
$comment vsprintf('<a href="member_id=%1$s">%2$s %3$s</a> logged in.'unserialize($log['log_text'])); 
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB