Q:

Codeigniter return null array from user function

I wrote a user library:
class Likeredis
{

    public function __construct($data = array()){
       return $this->init();
    }

   public function init(){
      return array('id' => 3); // Full array
   }
}

Call function:
$comment = $this->load->library('likeredis', array());

Output:
var_dump($comment); // IS NULL

Why I get null array?

A:

Looks like you have a casing problem, remember that class names always begin with an uppercase letter. Try this:
$comment = $this->load->library('Likeredis', array());

Additionally, I think there may be a conceptual problem regarding objects. Been a few years since I've used the codeigniter framework and I'm not sure what the loader your using does but typically the constructor of a class does not have a return value and instead returns an instantiation of the class by default which is commonly referred to as an object. You would then access the array which should be added as a member of the class if appropriate. Perhaps it would help to explain what you want to use your class for.
https://ellislab.com/codeigniter/user-guide/libraries/loader.html
Based on the above documentation it looks like you want to access your object in a manner more like this:
$this->load->library('linkeredis', array());
$comment = $this->linkerdis->init();
var_dump($comment);

...And I'm still not totally convinced about the casing not being a problem.

