title: How to update value by Events in CodeIgniter 4
body: <p>Here is my code:</p>
  <p><strong>\app\Controllers\My_controller.php</strong></p>
  <pre><code>namespace App\Controllers;
  
  use CodeIgniter\Events\Events;
  
  class My_controller extends App_Controller {
  
      function __construct() {
          parent::__construct();
          require_once(APPPATH . &quot;update_value.php&quot;);
      }
  
      function index() {
          $array = array(&quot;foo&quot;, &quot;bar&quot;);
          Events::trigger('add_value_to_array', $array);
  
          print_r($array);
      }
  
  }
  </code></pre>
  <p><strong>\app\update_value.php</strong></p>
  <pre><code>use CodeIgniter\Events\Events;
  
  Events::on('add_value_to_array', function($array) {
      error_log(&quot;add_value_to_array&quot; . PHP_EOL, 3, &quot;events.txt&quot;);
      array_push($array, &quot;new&quot;);
      return $array;
  });
  </code></pre>
  <p>I'm getting this output:</p>
  <p><code>Array ( [0] =&gt; foo [1] =&gt; bar )</code></p>
  <p>But it's triggering the event because it's giving a log containing this text: <code>add_value_to_array</code></p>
  <p>I want the updated array containing the 'new' item. My expected result:</p>
  <p><code>Array ( [0] =&gt; foo [1] =&gt; bar [2] =&gt; new  )</code></p>
  <p>Is it possible? Thanks in advance.</p>