Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Custom attribute

get: fn ($value) => ["user", "editor", "admin"][$value]

I have only seen that code from youtube but I don’t understand what this line of code does. Does this work like a map in php?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That’s an arrow function: https://www.php.net/manual/en/functions.arrow.php

That code is equivalent to this:

get: function ($value) {
    $arr = ["user", "editor", "admin"];

    return $arr[$value];
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading