Adjacency list with array data
Your code is really good, so there's not much to improve on, that I can see, but nonetheless:



You shouldn't have whitespace before, or inside your brackets unless required:


   $return = $input[ array_search($element, array_column($input, 'id')) ];
                    ^                                                  ^
   $str [] = $return ['name'];
       ^            ^
   if($return ['parent'] != 0) {
             ^
       $str [] = path($return ['parent'], $input);
           ^                 ^



All these lines above have unnecessary whitespace, however the line below is missing whitespace after the comma in path().


var_dump(path(13,$in));
                 ^





You really ought not to name your variables $return or $str, because the first is a system keyword, and the second is undescriptive &amp; possibly confusing as it's really an array, not a string.



The implode string -&gt; could also be -&gt; with an extra space, or even a unicode long (or not long) rightwards arrow: ⟶, along with the extra space, visually output would be more readable, and better looking.

13 - Anniversary -&gt; New arrives -&gt; Discount // With added space
13 - Anniversary ⟶ New arrives ⟶ Discount // With added space and long rightwards arrow