Access array returned by a function in php

前端 未结 5 519
抹茶落季
抹茶落季 2020-11-22 12:43

I\'m using a template engine that inserts code in my site where I want it.

I wrote a function to test for something which is quite easy:

myfunction()         


        
5条回答
  •  死守一世寂寞
    2020-11-22 13:06

    Ok... apparently there really isn't a better way, so I'm going to answer myself with a not so beautiful solution:

    I created the function:

    arrayGet($array, $index) { return $array[$index]; }
    

    And used it like this:

    myfunction() { return '(arrayGet(arrayGet($this, "a"), "b") ? true : false)' }
    

    This is not pretty but works.

提交回复
热议问题