php - Get vsprintf() to set 3rd argument / lastname


In my serialize() I have 3 arguments. Member id, firtname, and lastname


As you can see it only out puts the first name

Current Output

<a href="">John</a>

What it should be

<a href="">John Doe</a>

Question: How can I make sure can get last name as well in 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(

        $replace = array(

        $this->data['logs'][] = array(
            'comment' => str_replace($find, $replace, $comment),
            'date_added' => date("F jS, Y H:i:s A", $log['log_date'])



I have got solution now added%3$s

$comment = vsprintf('<a href="member_id=%d">%s %3$s</a> logged in.', unserialize($log['log_text']));

People are also looking for solutions to the problem: php - My website started to load slow after I added mysqli


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.