This is because you are returning an object of JsonModel from method toJsonModel. 

return new JsonModel($data);


So, every object has some properties that you can use to manipulate data. See the docs of Zend\View\Model\JsonModel here

So actually the values are not wrong but there is a way to access properties of an object.

Update

Attaching dispatch event

public function onBootstrap($e)
{
    // some stuff
    $eventManager = $e-&gt;getApplication()-&gt;getEventManager();
    $eventManager-&gt;attach("dispatch", function($e) {
        echo "Dispatch!";
    });
    // some stuff
}


Controller dispatch error in Zend framework 2
How to find the distance using dot product from point $A$ to the line through $B$ and $C$?

The points are $A = (2, -6, 1)$, $B = (3, 4, -2)$ and $C = (7, -1, 5)$.

I have tried this method: $$d=\frac{||BC \times BA||}{||BC||}$$

Please tell me how to find the distance using dot product.
