Search code examples
kohanakohana-3kohana-orm

How to find last key in orm object of Kohana


I want to display the all users name with ,(comma) and dont want comma after last name.

Code:

$users = ORM::factory('users')->find_all();

foreach($users as $user){
   echo $user->name . ',';
}

This gives output

jimy, mark, larry,

But i dont want the last comma.


Solution

  • $users = ORM::factory('users')->find_all();
    
    echo implode(',', $user->as_array(NULL, 'name'));